diff --git a/ets2panda/linter/arkanalyzer/OAT.xml b/ets2panda/linter/arkanalyzer/OAT.xml index 642093936053babe5d8da7bdfa8add284ca5bb60..a33eba98c976d5cdaec8e23aa741d143defe9b80 100644 --- a/ets2panda/linter/arkanalyzer/OAT.xml +++ b/ets2panda/linter/arkanalyzer/OAT.xml @@ -19,6 +19,7 @@ + diff --git a/ets2panda/linter/arkanalyzer/config/arkanalyzer.json b/ets2panda/linter/arkanalyzer/config/arkanalyzer.json index fe0c60bdc46c6a41afedd532ca45aed9128f4e1e..17df9e7480cfa69fc9a5f6caa0fe3a8a67f94ef6 100644 --- a/ets2panda/linter/arkanalyzer/config/arkanalyzer.json +++ b/ets2panda/linter/arkanalyzer/config/arkanalyzer.json @@ -7,15 +7,19 @@ ".d.ts" ], "enableLeadingComments": false, + "enableBuiltIn": true, "ignoreFileNames": [ "oh_modules", "node_modules", "build-tools", - "hvigorfile.ts" + "hvigorfile.ts", + "hvigorfile.js", + "hvigor-wrapper.js" ], "sdkGlobalFolders": [ "component", - "@internal" + "@internal", + "ohos-typescript" ], "tsconfig": "tsconfig.json" } \ No newline at end of file diff --git a/ets2panda/linter/arkanalyzer/src/Config.ts b/ets2panda/linter/arkanalyzer/src/Config.ts index bff8ddf474ca034ddd0a8478c982dbdff0b2e6a5..45645d8783ac067b85c075654ee4078e8c3be34e 100644 --- a/ets2panda/linter/arkanalyzer/src/Config.ts +++ b/ets2panda/linter/arkanalyzer/src/Config.ts @@ -43,6 +43,7 @@ export interface SceneOptions { ignoreFileNames?: string[]; enableLeadingComments?: boolean; enableTrailingComments?: boolean; + enableBuiltIn?: boolean; tsconfig?: string; isScanAbc?: boolean; sdkGlobalFolders?: string[]; @@ -86,6 +87,7 @@ export class SceneConfig { public buildConfig(targetProjectName: string, targetProjectDirectory: string, sdks: Sdk[], fullFilePath?: string[]): void { this.targetProjectName = targetProjectName; this.targetProjectDirectory = targetProjectDirectory; + this.projectFiles = getAllFiles(targetProjectDirectory, this.options.supportFileExts!, this.options.ignoreFileNames); this.sdksObj = sdks; if (fullFilePath) { this.projectFiles.push(...fullFilePath); diff --git a/ets2panda/linter/arkanalyzer/src/Scene.ts b/ets2panda/linter/arkanalyzer/src/Scene.ts index 72c782822638b95a35109c472eeaa37aaaf1e76f..cc41afcc09b4cf2ade58b3153885fc23c8b8ce55 100644 --- a/ets2panda/linter/arkanalyzer/src/Scene.ts +++ b/ets2panda/linter/arkanalyzer/src/Scene.ts @@ -41,16 +41,18 @@ import { ImportInfo } from './core/model/ArkImport'; import { ALL, CONSTRUCTOR_NAME, TSCONFIG_JSON } from './core/common/TSConst'; import { BUILD_PROFILE_JSON5, OH_PACKAGE_JSON5 } from './core/common/EtsConst'; import { SdkUtils } from './core/common/SdkUtils'; +import { PointerAnalysisConfig } from './callgraph/pointerAnalysis/PointerAnalysisConfig'; +import { ValueUtil } from './core/common/ValueUtil'; const logger = Logger.getLogger(LOG_MODULE_TYPE.ARKANALYZER, 'Scene'); enum SceneBuildStage { BUILD_INIT, + SDK_INFERRED, CLASS_DONE, METHOD_DONE, CLASS_COLLECTED, METHOD_COLLECTED, - SDK_INFERRED, TYPE_INFERRED, } @@ -99,6 +101,17 @@ export class Scene { constructor() {} + /* + * Set all static field to be null, then all related objects could be freed by GC. + * This method could be called before drop Scene. + */ + public dispose(): void { + PointerAnalysisConfig.dispose(); + SdkUtils.dispose(); + ValueUtil.dispose(); + ModelUtils.dispose(); + } + public getOptions(): SceneOptions { return this.options; } @@ -194,6 +207,9 @@ export class Scene { } // handle sdks + if (this.options.enableBuiltIn && !sceneConfig.getSdksObj().find(sdk => sdk.name === SdkUtils.BUILT_IN_NAME)) { + sceneConfig.getSdksObj().unshift(SdkUtils.BUILT_IN_SDK); + } sceneConfig.getSdksObj()?.forEach(sdk => { if (!sdk.moduleName) { this.buildSdk(sdk.name, sdk.path); @@ -207,7 +223,16 @@ export class Scene { } } }); - + if (this.buildStage < SceneBuildStage.SDK_INFERRED) { + this.sdkArkFilesMap.forEach(file => { + IRInference.inferFile(file); + SdkUtils.mergeGlobalAPI(file, this.sdkGlobalMap); + }); + this.sdkArkFilesMap.forEach(file => { + SdkUtils.postInferredSdk(file, this.sdkGlobalMap); + }); + this.buildStage = SceneBuildStage.SDK_INFERRED; + } this.fileLanguages = sceneConfig.getFileLanguages(); } @@ -222,6 +247,7 @@ export class Scene { return; } const buildProfileJson = parseJsonText(configurationsText); + SdkUtils.setEsVersion(buildProfileJson); const modules = buildProfileJson.modules; if (modules instanceof Array) { modules.forEach(module => { @@ -322,12 +348,13 @@ export class Scene { } } + ModelUtils.dispose(); this.buildStage = SceneBuildStage.METHOD_DONE; } private genArkFiles(): void { this.projectFiles.forEach(file => { - logger.info('=== parse file:', file); + logger.trace('=== parse file:', file); try { const arkFile: ArkFile = new ArkFile(FileUtils.getFileLanguage(file, this.fileLanguages)); arkFile.setScene(this); @@ -469,9 +496,11 @@ export class Scene { } private findDependenciesByRule(originPath: string, arkFile: ArkFile): void { - const extNameArray = ['.ets', '.ts', '.d.ets', '.d.ts', '.js']; - if (!this.findFilesByPathArray(originPath, this.indexPathArray, arkFile) && !this.findFilesByExtNameArray(originPath, extNameArray, arkFile)) { - logger.info(originPath + 'module mapperInfo is not found!'); + if ( + !this.findFilesByPathArray(originPath, this.indexPathArray, arkFile) && + !this.findFilesByExtNameArray(originPath, this.options.supportFileExts!, arkFile) + ) { + logger.trace(originPath + 'module mapperInfo is not found!'); } } @@ -542,7 +571,7 @@ export class Scene { this.addFileNode2DependencyGrap(originPath, arkFile); } if (!this.findFilesByPathArray(originPath, this.indexPathArray, arkFile)) { - logger.info(originPath + 'module mapperInfo is not found!'); + logger.trace(originPath + 'module mapperInfo is not found!'); } } } @@ -572,9 +601,10 @@ export class Scene { } private buildSdk(sdkName: string, sdkPath: string): void { - const allFiles = getAllFiles(sdkPath, this.options.supportFileExts!, this.options.ignoreFileNames); + const allFiles = sdkName === SdkUtils.BUILT_IN_NAME ? SdkUtils.fetchBuiltInFiles() : + getAllFiles(sdkPath, this.options.supportFileExts!, this.options.ignoreFileNames); allFiles.forEach(file => { - logger.info('=== parse sdk file:', file); + logger.trace('=== parse sdk file:', file); try { const arkFile: ArkFile = new ArkFile(FileUtils.getFileLanguage(file, this.fileLanguages)); arkFile.setScene(this); @@ -586,7 +616,7 @@ export class Scene { const fileSig = arkFile.getFileSignature().toMapKey(); this.sdkArkFilesMap.set(fileSig, arkFile); SdkUtils.buildSdkImportMap(arkFile); - SdkUtils.buildGlobalMap(arkFile, this.sdkGlobalMap); + SdkUtils.loadGlobalAPI(arkFile, this.sdkGlobalMap); } catch (error) { logger.error('Error parsing file:', file, error); this.unhandledSdkFilePaths.push(file); @@ -1023,16 +1053,7 @@ export class Scene { ``` */ public inferTypes(): void { - if (this.buildStage < SceneBuildStage.SDK_INFERRED) { - this.sdkArkFilesMap.forEach(file => { - try { - IRInference.inferFile(file); - } catch (error) { - logger.error('Error inferring types of sdk file:', file.getFileSignature(), error); - } - }); - this.buildStage = SceneBuildStage.SDK_INFERRED; - } + this.filesMap.forEach(file => { try { IRInference.inferFile(file); @@ -1044,6 +1065,7 @@ export class Scene { this.getMethodsMap(true); this.buildStage = SceneBuildStage.TYPE_INFERRED; } + SdkUtils.dispose(); } /** @@ -1458,7 +1480,7 @@ export class ModuleScene { private genArkFiles(supportFileExts: string[]): void { getAllFiles(this.modulePath, supportFileExts, this.projectScene.getOptions().ignoreFileNames).forEach(file => { - logger.info('=== parse file:', file); + logger.trace('=== parse file:', file); try { const arkFile: ArkFile = new ArkFile(FileUtils.getFileLanguage(file, this.projectScene.getFileLanguages())); arkFile.setScene(this.projectScene); diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/AbstractAnalysis.ts b/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/AbstractAnalysis.ts index 4fb8a6f7b7185608987af0b265e98a098ee24047..9a3e7fa8e184f04adbc9c186b35f3e11e13fd64e 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/AbstractAnalysis.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/AbstractAnalysis.ts @@ -30,13 +30,14 @@ const logger = Logger.getLogger(LOG_MODULE_TYPE.ARKANALYZER, 'CG'); export abstract class AbstractAnalysis { protected scene: Scene; - protected cg!: CallGraph; + protected cg: CallGraph; protected cgBuilder!: CallGraphBuilder; protected workList: FuncID[] = []; protected processedMethod!: IPtsCollection; - constructor(s: Scene) { + constructor(s: Scene, cg: CallGraph) { this.scene = s; + this.cg = cg; } public getScene(): Scene { @@ -96,11 +97,13 @@ export abstract class AbstractAnalysis { } public projectStart(displayGeneratedMethod: boolean): void { - this.scene.getMethods().forEach((method) => { - let cgNode = this.cg.getCallGraphNodeByMethod(method.getSignature()) as CallGraphNode; + this.cgBuilder.buildCGNodes(this.scene.getMethods()); + + for (let n of this.cg.getNodesIter()) { + let cgNode = n as CallGraphNode; if (cgNode.isSdkMethod()) { - return; + continue; } this.preProcessMethod(cgNode.getID()); @@ -108,7 +111,9 @@ export abstract class AbstractAnalysis { this.processMethod(cgNode.getID()).forEach((cs: CallSite) => { this.processCallSite(cgNode.getID(), cs, displayGeneratedMethod, true); }); - }); + } + + this.cgBuilder.setEntries(); } private processCallSite(method: FuncID, cs: CallSite, displayGeneratedMethod: boolean, isProject: boolean = false): void { @@ -128,7 +133,7 @@ export abstract class AbstractAnalysis { if (displayGeneratedMethod || !me?.isGenerated()) { this.workList.push(cs.calleeFuncID); - logger.info(`New workList item ${cs.calleeFuncID}: ${this.cg.getArkMethodByFuncID(cs.calleeFuncID)?.getSignature().toString()}`); + logger.trace(`New workList item ${cs.calleeFuncID}: ${this.cg.getArkMethodByFuncID(cs.calleeFuncID)?.getSignature().toString()}`); } } diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/ClassHierarchyAnalysis.ts b/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/ClassHierarchyAnalysis.ts index 029d85541ea8172eeeaf5b3bb1cd21b0aa67df9e..df58f9e5712d064aedbfc6b7a9fda02f9676861d 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/ClassHierarchyAnalysis.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/ClassHierarchyAnalysis.ts @@ -20,11 +20,12 @@ import { ArkClass } from '../../core/model/ArkClass'; import { NodeID } from '../../core/graph/BaseExplicitGraph'; import { CallGraph, CallSite } from '../model/CallGraph'; import { AbstractAnalysis } from './AbstractAnalysis'; +import { CallGraphBuilder } from '../model/builder/CallGraphBuilder'; export class ClassHierarchyAnalysis extends AbstractAnalysis { - constructor(scene: Scene, cg: CallGraph) { - super(scene); - this.cg = cg; + constructor(scene: Scene, cg: CallGraph, cb: CallGraphBuilder) { + super(scene, cg); + this.cgBuilder = cb; } public resolveCall(callerMethod: NodeID, invokeStmt: Stmt): CallSite[] { diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/RapidTypeAnalysis.ts b/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/RapidTypeAnalysis.ts index b4ecc267ac48cc1ed19e38c685663ef8195fa732..b14816d26bbac4e37aeb443a553c5875447fc052 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/RapidTypeAnalysis.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/algorithm/RapidTypeAnalysis.ts @@ -33,8 +33,7 @@ export class RapidTypeAnalysis extends AbstractAnalysis { private ignoredCalls: Map> = new Map(); constructor(scene: Scene, cg: CallGraph) { - super(scene); - this.cg = cg; + super(scene, cg); } public resolveCall(callerMethod: NodeID, invokeStmt: Stmt): CallSite[] { diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/common/Statistics.ts b/ets2panda/linter/arkanalyzer/src/callgraph/common/Statistics.ts index 61246908adb1ecf0ba1446fa8a77d7860d0fb458..112539b16867550716b2818687ef2af0acf279d2 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/common/Statistics.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/common/Statistics.ts @@ -196,6 +196,7 @@ export class CGStat extends StatTraits { numVirtual: number = 0; numIntrinsic: number = 0; numConstructor: number = 0; + numBlank: number = 0; public startStat(): void { this.startTime = new Date().getTime(); @@ -221,6 +222,7 @@ export class CGStat extends StatTraits { this.numIntrinsic++; break; default: + this.numBlank++; } this.numTotalNode++; } @@ -232,7 +234,8 @@ export class CGStat extends StatTraits { output = output + `Real function\t\t${this.numReal}\n`; output = output + `Intrinsic function\t${this.numIntrinsic}\n`; output = output + `Constructor function\t${this.numConstructor}\n`; - output = output + `Blank function\t\t${this.numVirtual}\n`; + output = output + `Virtual function\t\t${this.numVirtual}\n`; + output = output + `Blank function\t\t${this.numBlank}\n`; output = output + `Total\t\t\t${this.numTotalNode}\n`; return output; } diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/model/CallGraph.ts b/ets2panda/linter/arkanalyzer/src/callgraph/model/CallGraph.ts index 954f47804a2413dbdba1747ea31f02b19edc1cd6..0ddeb630076cbd606e014cdcaccc2bb5e60f7685 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/model/CallGraph.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/model/CallGraph.ts @@ -15,63 +15,27 @@ import { MethodSignature } from '../../core/model/ArkSignature'; import { Stmt } from '../../core/base/Stmt'; -import { Value } from '../../core/base/Value'; import { Scene } from '../../Scene'; import { ArkMethod } from '../../core/model/ArkMethod'; import { GraphPrinter } from '../../save/GraphPrinter'; import { PrinterBuilder } from '../../save/PrinterBuilder'; import { BaseEdge, BaseNode, BaseExplicitGraph, NodeID } from '../../core/graph/BaseExplicitGraph'; import { CGStat } from '../common/Statistics'; -import { ContextID } from '../pointerAnalysis/Context'; import { UNKNOWN_FILE_NAME } from '../../core/common/Const'; +import { CallSite, CallSiteID, DynCallSite, ICallSite } from './CallSite'; export type Method = MethodSignature; -export type CallSiteID = number; export type FuncID = number; type StmtSet = Set; +export { CallSite, DynCallSite, ICallSite }; + export enum CallGraphNodeKind { - real, + real, // method from project and has body vitual, - intrinsic, - constructor, -} - -export class CallSite { - public callStmt: Stmt; - public args: Value[] | undefined; - public calleeFuncID: FuncID; - public callerFuncID: FuncID; - - constructor(s: Stmt, a: Value[] | undefined, ce: FuncID, cr: FuncID) { - this.callStmt = s; - this.args = a; - this.calleeFuncID = ce; - this.callerFuncID = cr; - } -} - -export class DynCallSite { - public callerFuncID: FuncID; - public callStmt: Stmt; - public args: Value[] | undefined; - public protentialCalleeFuncID: FuncID | undefined; - - constructor(caller: FuncID, s: Stmt, a: Value[] | undefined, ptcCallee: FuncID | undefined) { - this.callerFuncID = caller; - this.callStmt = s; - this.args = a; - this.protentialCalleeFuncID = ptcCallee; - } -} - -export class CSCallSite extends CallSite { - public cid: ContextID; - - constructor(id: ContextID, cs: CallSite) { - super(cs.callStmt, cs.args, cs.calleeFuncID, cs.callerFuncID); - this.cid = id; - } + intrinsic, // method created by AA, which arkMethod.isGenrated is true + constructor, // constructor + blank, // method without body } export class CallGraphEdge extends BaseEdge { @@ -119,7 +83,6 @@ export class CallGraphEdge extends BaseEdge { export class CallGraphNode extends BaseNode { private method: Method; private ifSdkMethod: boolean = false; - private isBlank: boolean = false; constructor(id: number, m: Method, k: CallGraphNodeKind = CallGraphNodeKind.real) { super(id, k); @@ -139,11 +102,7 @@ export class CallGraphNode extends BaseNode { } public get isBlankMethod(): boolean { - return this.isBlank; - } - - public set isBlankMethod(is: boolean) { - this.isBlank = is; + return this.kind === CallGraphNodeKind.blank; } public getDotAttr(): string { @@ -195,11 +154,6 @@ export class CallGraph extends BaseExplicitGraph { // check if sdk method cgNode.setSdkMethod(this.scene.hasSdkFile(method.getDeclaringClassSignature().getDeclaringFileSignature())); - let arkMethod = this.scene.getMethod(method); - if (!arkMethod || !arkMethod.getCfg()) { - cgNode.isBlankMethod = true; - } - this.addNode(cgNode); this.methodToCGNodeMap.set(method.toString(), cgNode.getID()); this.cgStat.addNodeStat(kind); @@ -285,7 +239,7 @@ export class CallGraph extends BaseExplicitGraph { } let args = callStmt.getInvokeExpr()?.getArgs(); - let cs = new DynCallSite(callerNode.getID(), callStmt, args, calleeNode?.getID()); + let cs = new DynCallSite(callStmt, args, calleeNode?.getID(), callerNode.getID()); this.stmtToDynCallSitemap.set(callStmt, cs); } @@ -467,4 +421,4 @@ export class CallGraph extends BaseExplicitGraph { public getGraphName(): string { return 'CG'; } -} +} \ No newline at end of file diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/model/CallSite.ts b/ets2panda/linter/arkanalyzer/src/callgraph/model/CallSite.ts new file mode 100644 index 0000000000000000000000000000000000000000..40dbb3b492233cdcd519b3ac0ad6dc5b90a5fee4 --- /dev/null +++ b/ets2panda/linter/arkanalyzer/src/callgraph/model/CallSite.ts @@ -0,0 +1,64 @@ +/* + * 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 { Stmt } from '../../core/base/Stmt'; +import { Value } from '../../core/base/Value'; +import { ContextID } from '../pointerAnalysis/Context'; +import { FuncID } from './CallGraph'; + +export type CallSiteID = number; + +export interface ICallSite { + callStmt: Stmt; + args: Value[] | undefined; + callerFuncID: FuncID; +} + +export class CallSite implements ICallSite { + public callStmt: Stmt; + public args: Value[] | undefined; + public calleeFuncID: FuncID; + public callerFuncID: FuncID; + + constructor(s: Stmt, a: Value[] | undefined, ce: FuncID, cr: FuncID) { + this.callStmt = s; + this.args = a; + this.calleeFuncID = ce; + this.callerFuncID = cr; + } +} + +export class DynCallSite implements ICallSite { + public callStmt: Stmt; + public args: Value[] | undefined; + public protentialCalleeFuncID: FuncID | undefined; + public callerFuncID: FuncID; + + constructor(s: Stmt, a: Value[] | undefined, ptcCallee: FuncID | undefined, caller: FuncID) { + this.callerFuncID = caller; + this.callStmt = s; + this.args = a; + this.protentialCalleeFuncID = ptcCallee; + } +} + +export class CSCallSite extends CallSite { + public cid: ContextID; + + constructor(id: ContextID, cs: CallSite) { + super(cs.callStmt, cs.args, cs.calleeFuncID, cs.callerFuncID); + this.cid = id; + } +} \ No newline at end of file diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/model/builder/CallGraphBuilder.ts b/ets2panda/linter/arkanalyzer/src/callgraph/model/builder/CallGraphBuilder.ts index c631c4333fc41b233ee3fba8988fb5f0ebb530b3..5947b9c66e050cdca5474e002320b789939ebed0 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/model/builder/CallGraphBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/model/builder/CallGraphBuilder.ts @@ -38,19 +38,27 @@ export class CallGraphBuilder { this.setEntries(); } - public buildDirectCallGraph(methods: ArkMethod[]): void { + /* + * Create CG Node for ArkMethods + */ + public buildCGNodes(methods: ArkMethod[]): void { for (const method of methods) { let m = method.getSignature(); let kind = CallGraphNodeKind.real; if (method.isGenerated()) { kind = CallGraphNodeKind.intrinsic; - } - if (method.getName() === 'constructor') { + } else if (method.getBody() === undefined || method.getCfg() === undefined) { + kind = CallGraphNodeKind.blank; + } else if (method.getName() === 'constructor') { kind = CallGraphNodeKind.constructor; } this.cg.addCallGraphNode(m, kind); } + } + + public buildDirectCallGraph(methods: ArkMethod[]): void { + this.buildCGNodes(methods); for (const method of methods) { let cfg = method.getCfg(); @@ -70,8 +78,7 @@ export class CallGraphBuilder { if (callee && invokeExpr instanceof ArkStaticInvokeExpr) { this.cg.addDirectOrSpecialCallEdge(method.getSignature(), callee, stmt); } else if ( - callee && - invokeExpr instanceof ArkInstanceInvokeExpr && + callee && invokeExpr instanceof ArkInstanceInvokeExpr && (this.isConstructor(callee) || this.scene.getMethod(callee)?.isGenerated()) ) { this.cg.addDirectOrSpecialCallEdge(method.getSignature(), callee, stmt, false); @@ -89,12 +96,12 @@ export class CallGraphBuilder { }); this.cg.setEntries(cgEntries); - let classHierarchyAnalysis: ClassHierarchyAnalysis = new ClassHierarchyAnalysis(this.scene, this.cg); + let classHierarchyAnalysis: ClassHierarchyAnalysis = new ClassHierarchyAnalysis(this.scene, this.cg, this); classHierarchyAnalysis.start(displayGeneratedMethod); } public buildCHA4WholeProject(displayGeneratedMethod: boolean = false): void { - let classHierarchyAnalysis: ClassHierarchyAnalysis = new ClassHierarchyAnalysis(this.scene, this.cg); + let classHierarchyAnalysis: ClassHierarchyAnalysis = new ClassHierarchyAnalysis(this.scene, this.cg, this); classHierarchyAnalysis.projectStart(displayGeneratedMethod); } diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PTAUtils.ts b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PTAUtils.ts index a8940d5d3c21b561450e4ac051f3684fa728fb7e..0c120d6000b1192188cf68ebf52401f5d68aab3e 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PTAUtils.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PTAUtils.ts @@ -51,6 +51,7 @@ export function getBuiltInApiType(method: MethodSignature): BuiltApiType { return BuiltApiType.FunctionApply; case 'bind': return BuiltApiType.FunctionBind; + default: } } } diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PagBuilder.ts b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PagBuilder.ts index bd3917b09083d00bd5fdf67ae0129a69b8630daa..815eae1afbde02d7eccdd044872237a5cbc4ee9e 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PagBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PagBuilder.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { CallGraph, CallGraphNode, CallGraphNodeKind, CallSite, DynCallSite, FuncID } from '../model/CallGraph'; +import { CallGraph, CallGraphNode, CallGraphNodeKind, CallSite, DynCallSite, FuncID, ICallSite } from '../model/CallGraph'; import { Scene } from '../../Scene'; import { ArkAssignStmt, ArkInvokeStmt, ArkReturnStmt, Stmt } from '../../core/base/Stmt'; import { @@ -527,7 +527,7 @@ export class PagBuilder { }); } - public addDynamicCallEdge(cs: DynCallSite | CallSite, baseClassPTNode: NodeID, cid: ContextID): NodeID[] { + public addDynamicCallEdge(cs: ICallSite, baseClassPTNode: NodeID, cid: ContextID): NodeID[] { let srcNodes: NodeID[] = []; let ivkExpr = cs.callStmt.getInvokeExpr(); @@ -577,7 +577,7 @@ export class PagBuilder { * all possible callee methods of a dynamic call site * handle both PtrInvokeExpr and InstanceInvokeExpr */ - private getDynamicCallee(ptNode: PagNode, value: Value, ivkExpr: AbstractInvokeExpr, cs: DynCallSite | CallSite): ArkMethod[] { + private getDynamicCallee(ptNode: PagNode, value: Value, ivkExpr: AbstractInvokeExpr, cs: ICallSite): ArkMethod[] { let callee: ArkMethod[] = []; if (ptNode instanceof PagFuncNode) { @@ -646,7 +646,10 @@ export class PagBuilder { // Pass base's pts to callee's this pointer if (!dstCGNode.isSdkMethod() && ivkExpr instanceof ArkInstanceInvokeExpr) { let srcBaseNode = this.addThisRefCallEdge(baseClassPTNode, cid, ivkExpr.getBase(), callee!, calleeCid, staticCS.callerFuncID); - srcNodes.push(srcBaseNode); + + if (srcBaseNode !== -1) { + srcNodes.push(srcBaseNode); + } } else if (!dstCGNode.isSdkMethod() && ivkExpr instanceof ArkPtrInvokeExpr) { let originCS = (ptNode as PagFuncNode).getCS(); if (!originCS) { @@ -712,6 +715,7 @@ export class PagBuilder { */ this.handleFunctionBind(staticCS, cid, baseClassPTNode, srcNodes); break; + default: } return srcNodes; @@ -799,7 +803,11 @@ export class PagBuilder { private addThisEdge(staticCS: CallSite, cid: ContextID, realCallee: ArkMethod, srcNodes: NodeID[], baseClassPTNode: NodeID, calleeCid: ContextID): void { if (!(staticCS.args![0] instanceof NullConstant) && !realCallee.isStatic()) { - srcNodes.push(this.addThisRefCallEdge(baseClassPTNode, cid, staticCS.args![0] as Local, realCallee, calleeCid, staticCS.callerFuncID)); + let srcNodeID = this.addThisRefCallEdge(baseClassPTNode, cid, staticCS.args![0] as Local, realCallee, calleeCid, staticCS.callerFuncID); + + if (srcNodeID !== -1) { + srcNodes.push(srcNodeID); + } } } @@ -915,6 +923,10 @@ export class PagBuilder { callerFunID: FuncID ): NodeID { let thisRefNodeID = this.recordThisRefNode(baseClassPTNode, callee, calleeCid); + if (thisRefNodeID === -1) { + return -1; + } + let thisRefNode = this.pag.getNode(thisRefNodeID) as PagThisRefNode; let srcBaseLocal = baseLocal; srcBaseLocal = this.getRealThisLocal(srcBaseLocal, callerFunID); @@ -945,7 +957,7 @@ export class PagBuilder { .getCfg() ?.getStmts() .filter(s => s instanceof ArkAssignStmt && s.getRightOp() instanceof ArkThisRef); - let thisPtr = (thisAssignStmt?.at(0) as ArkAssignStmt).getRightOp() as ArkThisRef; + let thisPtr = (thisAssignStmt?.[0] as ArkAssignStmt).getRightOp() as ArkThisRef; if (!thisPtr) { throw new Error('Can not get this ptr'); } @@ -1031,8 +1043,8 @@ export class PagBuilder { // add args to parameters edges for (let i = offset; i <= args.length; i++) { - let arg = args.at(i); - let param = params.at(i - offset); + let arg = args[i]; + let param = params[i - offset]; if (!arg || !param) { return srcNodes; } @@ -1063,7 +1075,7 @@ export class PagBuilder { // container value is the base value of callstmt, its points-to is PagNewContainerExprNode let srcNodes: NodeID[] = []; let containerValue = (callStmt.getInvokeExpr() as ArkInstanceInvokeExpr).getBase(); - let param = params.at(0); + let param = params[0]; if (!containerValue || !param) { return srcNodes; } @@ -1200,7 +1212,7 @@ export class PagBuilder { // add args to parameters edges for (let i = 0; i < argNum; i++) { - let arg = cs.args?.at(i); + let arg = cs.args?.[i]; let paramValue; if (arg instanceof Local && arg.getType() instanceof FunctionType) { @@ -1233,7 +1245,7 @@ export class PagBuilder { let sdkParamInvokeStmt = new ArkInvokeStmt(new ArkPtrInvokeExpr((arg.getType() as FunctionType).getMethodSignature(), paramValue as Local, [])); // create new DynCallSite - let sdkParamCallSite = new DynCallSite(funcID, sdkParamInvokeStmt, undefined, undefined); + let sdkParamCallSite = new DynCallSite(sdkParamInvokeStmt, undefined, undefined, funcID); dstPagNode.addRelatedDynCallSite(sdkParamCallSite); } @@ -1542,7 +1554,7 @@ export class PagBuilder { * process Storage API * @returns boolean: check if the cs represent a Storage API, no matter the API will success or fail */ - private processStorage(cs: CallSite | DynCallSite, calleeCGNode: CallGraphNode, cid: ContextID): boolean { + private processStorage(cs: ICallSite, calleeCGNode: CallGraphNode, cid: ContextID): boolean { let storageName = calleeCGNode.getMethod().getDeclaringClassSignature().getClassName(); let storageType: StorageType = this.getStorageType(storageName, cs, cid); @@ -1570,7 +1582,7 @@ export class PagBuilder { return false; } - private processStorageSetOrCreate(cs: CallSite | DynCallSite, cid: ContextID): void { + private processStorageSetOrCreate(cs: ICallSite, cid: ContextID): void { let propertyStr = this.getPropertyName(cs.args![0]); if (!propertyStr) { return; @@ -1583,7 +1595,7 @@ export class PagBuilder { this.addPropertyLinkEdge(propertyNode, storageObj, cid, cs.callStmt, StorageLinkEdgeType.Local2Property); } - private processStorageLink(cs: CallSite | DynCallSite, cid: ContextID): void { + private processStorageLink(cs: ICallSite, cid: ContextID): void { let propertyStr = this.getPropertyName(cs.args![0]); if (!propertyStr) { return; @@ -1601,7 +1613,7 @@ export class PagBuilder { this.pag.addPagEdge(linkedOpNode, propertyNode, PagEdgeKind.Copy); } - private processStorageProp(cs: CallSite | DynCallSite, cid: ContextID): void { + private processStorageProp(cs: ICallSite, cid: ContextID): void { let propertyStr = this.getPropertyName(cs.args![0]); if (!propertyStr) { return; @@ -1618,7 +1630,7 @@ export class PagBuilder { this.pag.addPagEdge(propertyNode, linkedOpNode, PagEdgeKind.Copy); } - private processStorageSet(cs: CallSite | DynCallSite, cid: ContextID): void { + private processStorageSet(cs: ICallSite, cid: ContextID): void { let ivkExpr: AbstractInvokeExpr = cs.callStmt.getInvokeExpr()!; if (ivkExpr instanceof ArkInstanceInvokeExpr) { let base = ivkExpr.getBase(); @@ -1634,7 +1646,7 @@ export class PagBuilder { } } - private processStorageGet(cs: CallSite | DynCallSite, cid: ContextID): void { + private processStorageGet(cs: ICallSite, cid: ContextID): void { if (!(cs.callStmt instanceof ArkAssignStmt)) { return; } @@ -1686,7 +1698,7 @@ export class PagBuilder { * @param cid: for search PAG node in SubscribedAbstractProperty * @returns StorageType enum */ - private getStorageType(storageName: string, cs: CallSite | DynCallSite, cid: ContextID): StorageType { + private getStorageType(storageName: string, cs: ICallSite, cid: ContextID): StorageType { switch (storageName) { case 'AppStorage': return StorageType.APP_STORAGE; diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysis.ts b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysis.ts index 902a05b902faa419cf511850bd2ccc1871a915fc..4fc4a16471955a8a6b426e88b5cab661b91adf19 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysis.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysis.ts @@ -47,9 +47,8 @@ export class PointerAnalysis extends AbstractAnalysis { private config: PointerAnalysisConfig; constructor(p: Pag, cg: CallGraph, s: Scene, config: PointerAnalysisConfig) { - super(s); + super(s, cg); this.pag = p; - this.cg = cg; this.ptd = new DiffPTData>(config.ptsCollectionCtor); this.pagBuilder = new PagBuilder(this.pag, this.cg, s, config.kLimit, config.analysisScale); this.cgBuilder = new CallGraphBuilder(this.cg, s); diff --git a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysisConfig.ts b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysisConfig.ts index 1e68c981db8221514da887c76692e267a90cbe2f..c42428087ea34efcfd9c1c3bbe66c42924a5eb14 100644 --- a/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysisConfig.ts +++ b/ets2panda/linter/arkanalyzer/src/callgraph/pointerAnalysis/PointerAnalysisConfig.ts @@ -64,6 +64,15 @@ export class PointerAnalysisConfig { } } + /* + * Set static field to be null, then all related objects could be freed by GC. + * Class PointerAnalysisConfig has been exported by ArkAnalyzer, the dispose method should be called by users themselves before free this class. + */ + public static dispose(): void { + // @ts-expect-error: only be used to free the memory + this.instance = null; + } + /* * Create Singleton instance * The instance can be created multi-times and be overwrited diff --git a/ets2panda/linter/arkanalyzer/src/core/base/Expr.ts b/ets2panda/linter/arkanalyzer/src/core/base/Expr.ts index dcf4695331ac437403e3d04b0ce248b533806264..521e96707926f221fea721b965a11de31d41903d 100644 --- a/ets2panda/linter/arkanalyzer/src/core/base/Expr.ts +++ b/ets2panda/linter/arkanalyzer/src/core/base/Expr.ts @@ -19,11 +19,13 @@ import { MethodSignature } from '../model/ArkSignature'; import { Local } from './Local'; import { AliasType, + AnyType, ArrayType, BigIntType, BooleanType, ClassType, FunctionType, + GenericType, NullType, NumberType, StringType, @@ -40,8 +42,9 @@ import { ArkMethod } from '../model/ArkMethod'; import { UNKNOWN_FILE_NAME } from '../common/Const'; import { IRInference } from '../common/IRInference'; import { ImportInfo } from '../model/ArkImport'; -import { ArkClass } from '../model/ArkClass'; +import { ArkClass, ClassCategory } from '../model/ArkClass'; import { ArkField } from '../model/ArkField'; +import { ModelUtils } from '../common/ModelUtils'; /** * @category core/base/expr @@ -133,7 +136,8 @@ export abstract class AbstractInvokeExpr extends AbstractExpr { public getType(): Type { const type = this.methodSignature.getType(); - if (this.realGenericTypes) { + if (TypeInference.checkType(type, t => t instanceof GenericType || t instanceof AnyType) && + this.realGenericTypes) { return TypeInference.replaceTypeWithReal(type, this.realGenericTypes); } return type; @@ -342,14 +346,38 @@ export class ArkNewExpr extends AbstractExpr { const classSignature = this.classType.getClassSignature(); if (classSignature.getDeclaringFileSignature().getFileName() === UNKNOWN_FILE_NAME) { const className = classSignature.getClassName(); - let type = TypeInference.inferUnclearRefName(className, arkMethod.getDeclaringArkClass()); + let type: Type | null | undefined = ModelUtils.findDeclaredLocal(new Local(className), arkMethod, 1)?.getType(); + if (TypeInference.isUnclearType(type)) { + type = TypeInference.inferUnclearRefName(className, arkMethod.getDeclaringArkClass()); + } + if (type instanceof AliasType) { + const originalType = TypeInference.replaceAliasType(type); + if (originalType instanceof FunctionType) { + type = originalType.getMethodSignature().getMethodSubSignature().getReturnType(); + } else { + type = originalType; + } + } if (type && type instanceof ClassType) { - let realGenericTypes = this.classType.getRealGenericTypes(); - this.classType = realGenericTypes ? new ClassType(type.getClassSignature(), realGenericTypes) : type; + const instanceType = this.constructorSignature(type, arkMethod) ?? type; + this.classType.setClassSignature(instanceType.getClassSignature()); + TypeInference.inferRealGenericTypes(this.classType.getRealGenericTypes(), arkMethod.getDeclaringArkClass()); } } return this; } + + private constructorSignature(type: ClassType, arkMethod: ArkMethod): ClassType | undefined { + const classConstructor = arkMethod.getDeclaringArkFile().getScene().getClass(type.getClassSignature()); + if (classConstructor?.getCategory() === ClassCategory.INTERFACE) { + const type = classConstructor.getMethodWithName('construct-signature')?.getReturnType(); + if (type) { + const returnType = TypeInference.replaceAliasType(type); + return returnType instanceof ClassType ? returnType : undefined; + } + } + return undefined; + } } export class ArkNewArrayExpr extends AbstractExpr { @@ -695,9 +723,13 @@ export abstract class AbstractBinopExpr extends AbstractExpr { case '^': case '<<': case '>>': + if (op1Type === NumberType.getInstance() && op2Type === NumberType.getInstance()) { + type = NumberType.getInstance(); + } if (op1Type === BigIntType.getInstance() && op2Type === BigIntType.getInstance()) { type = BigIntType.getInstance(); } + break; case '>>>': if (op1Type === NumberType.getInstance() && op2Type === NumberType.getInstance()) { type = NumberType.getInstance(); @@ -1042,10 +1074,14 @@ export class AliasTypeExpr extends AbstractExpr { public getType(): Type { function getTypeOfImportInfo(importInfo: ImportInfo): Type { const arkExport = importInfo.getLazyExportInfo()?.getArkExport(); - if (arkExport) { - return TypeInference.parseArkExport2Type(arkExport) ?? UnknownType.getInstance(); + const importClauseName = importInfo.getImportClauseName(); + let type; + if (importClauseName.includes('.') && arkExport instanceof ArkClass) { + type = TypeInference.inferUnclearRefName(importClauseName, arkExport); + } else if (arkExport) { + type = TypeInference.parseArkExport2Type(arkExport); } - return UnknownType.getInstance(); + return type ?? UnknownType.getInstance(); } const operator = this.getOriginalObject(); diff --git a/ets2panda/linter/arkanalyzer/src/core/base/Local.ts b/ets2panda/linter/arkanalyzer/src/core/base/Local.ts index aa4fbebdf0597b1972cea69e7fcdb70bba21b64b..18e6391330405f13357751f6389df351356c4e9f 100644 --- a/ets2panda/linter/arkanalyzer/src/core/base/Local.ts +++ b/ets2panda/linter/arkanalyzer/src/core/base/Local.ts @@ -14,13 +14,13 @@ */ import { Stmt } from './Stmt'; -import { ClassType, Type, UnknownType } from './Type'; +import { ClassType, FunctionType, Type, UnknownType } from './Type'; import { Value } from './Value'; import { TypeInference } from '../common/TypeInference'; import { ArkExport, ExportType } from '../model/ArkExport'; import { ClassSignature, LocalSignature, MethodSignature } from '../model/ArkSignature'; import { ArkSignatureBuilder } from '../model/builder/ArkSignatureBuilder'; -import { UNKNOWN_METHOD_NAME } from '../common/Const'; +import { NAME_PREFIX, UNKNOWN_METHOD_NAME } from '../common/Const'; import { ModifierType } from '../model/ArkBaseModel'; import { ArkMethod } from '../model/ArkMethod'; import { ModelUtils } from '../common/ModelUtils'; @@ -53,12 +53,18 @@ export class Local implements Value, ArkExport { if (this.name === THIS_NAME && this.type instanceof UnknownType) { const declaringArkClass = arkMethod.getDeclaringArkClass(); this.type = new ClassType(declaringArkClass.getSignature(), declaringArkClass.getRealTypes()); - } else if (TypeInference.isUnclearType(this.type)) { - const type = TypeInference.inferBaseType(this.name, arkMethod.getDeclaringArkClass()) ?? ModelUtils.findDeclaredLocal(this, arkMethod)?.getType(); + } else if (!this.name.startsWith(NAME_PREFIX) && TypeInference.isUnclearType(this.type)) { + const type = TypeInference.inferBaseType(this.name, arkMethod.getDeclaringArkClass()) ?? + ModelUtils.findDeclaredLocal(this, arkMethod)?.getType(); if (type) { this.type = type; } } + if (this.type instanceof FunctionType) { + this.type.getMethodSignature().getMethodSubSignature().getParameters() + .forEach(p => TypeInference.inferParameterType(p, arkMethod)); + TypeInference.inferSignatureReturnType(this.type.getMethodSignature(), arkMethod); + } return this; } diff --git a/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts b/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts index 31f9ecf635744368612a3a08b551ecca62c1b4a5..5ed77fbe20408949b807cf82f9d2b54df431cd93 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/ArkIRTransformer.ts @@ -46,7 +46,6 @@ import { DEFAULT, PROMISE } from './TSConst'; import { buildGenericType, buildModifiers, buildTypeParameters } from '../model/builder/builderUtils'; import { ArkValueTransformer } from './ArkValueTransformer'; import { ImportInfo } from '../model/ArkImport'; -import { TypeInference } from './TypeInference'; import { AbstractTypeExpr } from '../base/TypeExpr'; import { buildNormalArkClassFromArkMethod } from '../model/builder/ArkClassBuilder'; import { ArkClass } from '../model/ArkClass'; @@ -156,6 +155,8 @@ export class ArkIRTransformer { stmts = this.expressionInExportToStmts(node.expression); } else if (ts.isClassDeclaration(node)) { stmts = this.classDeclarationToStmts(node); + } else if (ts.isParameter(node)) { + stmts = this.parameterPropertyToStmts(node); } this.mapStmtsToTsStmt(stmts, node); @@ -190,6 +191,44 @@ export class ArkIRTransformer { return []; } + // This is only used to add class property assign stmts into constructor when it is with parameter property. + private parameterPropertyToStmts(paramNode: ts.ParameterDeclaration): Stmt[] { + if (paramNode.modifiers === undefined || !ts.isIdentifier(paramNode.name)) { + return []; + } + const fieldName = paramNode.name.text; + const arkClass = this.declaringMethod.getDeclaringArkClass(); + const fieldSignature = arkClass.getFieldWithName(fieldName)?.getSignature(); + const paramLocal = Array.from(this.getLocals()).find(local => local.getName() === fieldName); + if (fieldSignature === undefined || paramLocal === undefined) { + return []; + } + const leftOp = new ArkInstanceFieldRef(this.getThisLocal(), fieldSignature); + const fieldAssignStmt = new ArkAssignStmt(leftOp, paramLocal); + fieldAssignStmt.setOperandOriginalPositions([FullPosition.DEFAULT, FullPosition.DEFAULT, FullPosition.DEFAULT]); + + // If the parameter has initializer, the related stmts should be added into class instance init method. + const instInitMethodCfg = arkClass.getInstanceInitMethod().getBody()?.getCfg(); + const instInitStmts = instInitMethodCfg?.getStartingBlock()?.getStmts(); + if (paramNode.initializer && instInitStmts && instInitMethodCfg) { + const { + value: instanceInitValue, + valueOriginalPositions: instanceInitPositions, + stmts: instanceInitStmts, + } = this.tsNodeToValueAndStmts(paramNode.initializer); + const instanceAssignStmt = new ArkAssignStmt(leftOp, instanceInitValue); + instanceAssignStmt.setOperandOriginalPositions([FullPosition.DEFAULT, FullPosition.DEFAULT, ...instanceInitPositions]); + const newInstanceInitStmts = [...instanceInitStmts, instanceAssignStmt]; + + // All these stmts will be added into instance init method, while that method has completed the building. So all new stmts should set cfg here. + newInstanceInitStmts.forEach(stmt => stmt.setCfg(instInitMethodCfg)); + + // The last stmt of instance init method is return stmt, so all the initializer stmts should be added before return stmt. + instInitStmts.splice(instInitStmts.length - 1, 0, ...newInstanceInitStmts); + } + return [fieldAssignStmt]; + } + private returnStatementToStmts(returnStatement: ts.ReturnStatement): Stmt[] { const stmts: Stmt[] = []; if (returnStatement.expression) { @@ -339,12 +378,6 @@ export class ArkIRTransformer { let expr: AliasTypeExpr; if (ts.isImportTypeNode(rightOp)) { expr = this.resolveImportTypeNode(rightOp); - const typeObject = expr.getOriginalObject(); - if (typeObject instanceof ImportInfo && typeObject.getLazyExportInfo() !== null) { - const arkExport = typeObject.getLazyExportInfo()!.getArkExport(); - rightType = TypeInference.parseArkExport2Type(arkExport) ?? UnknownType.getInstance(); - aliasType.setOriginalType(rightType); - } } else if (ts.isTypeQueryNode(rightOp)) { const localName = rightOp.exprName.getText(this.sourceFile); const originalLocal = Array.from(this.arkValueTransformer.getLocals()).find(local => local.getName() === localName); @@ -402,8 +435,6 @@ export class ArkIRTransformer { importInfo.build(importClauseName, importType, importFrom, LineColPosition.buildFromNode(importTypeNode, this.sourceFile), 0); importInfo.setDeclaringArkFile(this.declaringMethod.getDeclaringArkFile()); - // Function getLazyExportInfo will automatically try to infer the export info if it's undefined at the beginning. - importInfo.getLazyExportInfo(); return new AliasTypeExpr(importInfo, importTypeNode.isTypeOf); } diff --git a/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts b/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts index 75d86894287526553dc8e0e7a656d10f280cc4da..a26b46ee66fc266a936d9a37abda91b06dfedc2e 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/ArkValueTransformer.ts @@ -299,6 +299,7 @@ export class ArkValueTransformer { const constructorInvokeStmt = new ArkInvokeStmt(constructorInvokeExpr); constructorInvokeStmt.setOperandOriginalPositions(constructorInvokeExprPositions); stmts.push(constructorInvokeStmt); + return { value: newExprLocal, valueOriginalPositions: newExprLocalPositions, @@ -832,6 +833,11 @@ export class ArkValueTransformer { } else { invokeValue = new ArkStaticInvokeExpr(methodSignature, args, realGenericTypes); } + } else if (callerValue instanceof ArkArrayRef && ts.isElementAccessExpression(functionNameNode)) { + const methodSignature = ArkSignatureBuilder.buildMethodSignatureFromMethodName(functionNameNode.argumentExpression.getText()); + invokeValue = new ArkInstanceInvokeExpr(callerValue.getBase(), methodSignature, args, realGenericTypes); + invokeValuePositions.push(...callerPositions.slice(1)); + stmts.pop(); } else { ({ value: callerValue, @@ -1107,15 +1113,24 @@ export class ArkValueTransformer { private prefixUnaryExpressionToValueAndStmts(prefixUnaryExpression: ts.PrefixUnaryExpression): ValueAndStmts { const stmts: Stmt[] = []; - let { value: operandValue, valueOriginalPositions: operandPositions, stmts: operandStmts } = this.tsNodeToValueAndStmts(prefixUnaryExpression.operand); + let { + value: originOperandValue, + valueOriginalPositions: originOperandPositions, + stmts: operandStmts, + } = this.tsNodeToValueAndStmts(prefixUnaryExpression.operand); operandStmts.forEach(stmt => stmts.push(stmt)); - if (IRUtils.moreThanOneAddress(operandValue)) { + let operandValue: Value; + let operandPositions: FullPosition[]; + if (IRUtils.moreThanOneAddress(originOperandValue)) { ({ value: operandValue, valueOriginalPositions: operandPositions, stmts: operandStmts, - } = this.arkIRTransformer.generateAssignStmtForValue(operandValue, operandPositions)); + } = this.arkIRTransformer.generateAssignStmtForValue(originOperandValue, originOperandPositions)); operandStmts.forEach(stmt => stmts.push(stmt)); + } else { + operandValue = originOperandValue; + operandPositions = originOperandPositions; } const operatorToken = prefixUnaryExpression.operator; @@ -1127,17 +1142,14 @@ export class ArkValueTransformer { const assignStmt = new ArkAssignStmt(operandValue, binopExpr); assignStmt.setOperandOriginalPositions([...operandPositions, ...exprPositions]); stmts.push(assignStmt); - return { - value: operandValue, - valueOriginalPositions: operandPositions, - stmts: stmts, - }; + if (operandValue !== originOperandValue) { + const lastAssignStmt = new ArkAssignStmt(originOperandValue, operandValue); + lastAssignStmt.setOperandOriginalPositions([...originOperandPositions, ...operandPositions]); + stmts.push(lastAssignStmt); + } + return { value: originOperandValue, valueOriginalPositions: originOperandPositions, stmts: stmts }; } else if (operatorToken === ts.SyntaxKind.PlusToken) { - return { - value: operandValue, - valueOriginalPositions: operandPositions, - stmts: stmts, - }; + return { value: operandValue, valueOriginalPositions: operandPositions, stmts: stmts }; } else { let unopExpr: Value; const operator = ArkIRTransformer.tokenToUnaryOperator(operatorToken); @@ -1148,28 +1160,32 @@ export class ArkValueTransformer { unopExpr = ValueUtil.getUndefinedConst(); exprPositions = [FullPosition.DEFAULT]; } - return { - value: unopExpr, - valueOriginalPositions: exprPositions, - stmts: stmts, - }; + return { value: unopExpr, valueOriginalPositions: exprPositions, stmts: stmts }; } } private postfixUnaryExpressionToValueAndStmts(postfixUnaryExpression: ts.PostfixUnaryExpression): ValueAndStmts { const stmts: Stmt[] = []; - let { value: operandValue, valueOriginalPositions: operandPositions, stmts: exprStmts } = this.tsNodeToValueAndStmts(postfixUnaryExpression.operand); + let { + value: originOperandValue, + valueOriginalPositions: originOperandPositions, + stmts: exprStmts, + } = this.tsNodeToValueAndStmts(postfixUnaryExpression.operand); exprStmts.forEach(stmt => stmts.push(stmt)); - if (IRUtils.moreThanOneAddress(operandValue)) { + let operandValue: Value; + let operandPositions: FullPosition[]; + if (IRUtils.moreThanOneAddress(originOperandValue)) { ({ value: operandValue, valueOriginalPositions: operandPositions, stmts: exprStmts, - } = this.arkIRTransformer.generateAssignStmtForValue(operandValue, operandPositions)); + } = this.arkIRTransformer.generateAssignStmtForValue(originOperandValue, originOperandPositions)); exprStmts.forEach(stmt => stmts.push(stmt)); + } else { + operandValue = originOperandValue; + operandPositions = originOperandPositions; } - let value: Value; let exprPositions = [FullPosition.buildFromNode(postfixUnaryExpression, this.sourceFile)]; const operatorToken = postfixUnaryExpression.operator; if (operatorToken === ts.SyntaxKind.PlusPlusToken || operatorToken === ts.SyntaxKind.MinusMinusToken) { @@ -1179,15 +1195,21 @@ export class ArkValueTransformer { const assignStmt = new ArkAssignStmt(operandValue, binopExpr); assignStmt.setOperandOriginalPositions([...operandPositions, ...exprPositions]); stmts.push(assignStmt); - value = operandValue; - } else { - value = ValueUtil.getUndefinedConst(); - exprPositions = [FullPosition.DEFAULT]; + if (operandValue !== originOperandValue) { + const lastAssignStmt = new ArkAssignStmt(originOperandValue, operandValue); + lastAssignStmt.setOperandOriginalPositions([...originOperandPositions, ...operandPositions]); + stmts.push(lastAssignStmt); + } + return { + value: originOperandValue, + valueOriginalPositions: originOperandPositions, + stmts: stmts, + }; } return { - value: value, - valueOriginalPositions: exprPositions, + value: ValueUtil.getUndefinedConst(), + valueOriginalPositions: [FullPosition.DEFAULT], stmts: stmts, }; } @@ -1921,7 +1943,8 @@ export class ArkValueTransformer { } private resolveTypeReferenceNode(typeReferenceNode: ts.TypeReferenceNode): Type { - const typeReferenceFullName = typeReferenceNode.typeName.getText(this.sourceFile); + const typeReferenceFullName = ts.isIdentifier(typeReferenceNode.typeName) ? typeReferenceNode.typeName.text : + typeReferenceNode.typeName.getText(this.sourceFile); if (typeReferenceFullName === Builtin.OBJECT) { return Builtin.OBJECT_CLASS_TYPE; } @@ -1935,12 +1958,11 @@ export class ArkValueTransformer { } if (!aliasTypeAndStmt) { - const typeName = typeReferenceNode.typeName.getText(this.sourceFile); - const local = this.locals.get(typeName); + const local = this.locals.get(typeReferenceFullName); if (local !== undefined) { return local.getType(); } - return new UnclearReferenceType(typeName, genericTypes); + return new UnclearReferenceType(typeReferenceFullName, genericTypes); } else { if (genericTypes.length > 0) { const oldAlias = aliasTypeAndStmt[0]; diff --git a/ets2panda/linter/arkanalyzer/src/core/common/Builtin.ts b/ets2panda/linter/arkanalyzer/src/core/common/Builtin.ts index 5c74ecf4d2d82d15fe7a9166ea515e14d7f18c3b..faf7eb215200d1191cf93c653fa29687b8ffec02 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/Builtin.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/Builtin.ts @@ -42,8 +42,8 @@ export class Builtin { public static BUILT_IN_CLASS_SIGNATURE_MAP = this.buildBuiltInClassSignatureMap(); // constants for iterator - public static ITERATOR_FUNCTION = 'iterator'; - public static ITERATOR = 'Iterator'; + public static ITERATOR_FUNCTION = 'Symbol.iterator'; + public static ITERATOR = 'IterableIterator'; public static ITERATOR_NEXT = 'next'; public static ITERATOR_RESULT = 'IteratorResult'; public static ITERATOR_RESULT_DONE = 'done'; diff --git a/ets2panda/linter/arkanalyzer/src/core/common/DummyMainCreater.ts b/ets2panda/linter/arkanalyzer/src/core/common/DummyMainCreater.ts index 3818ac805174fb65eddb74175543135802ed9d5b..4dc9c68041bcc69e7f159b9cf38d3ddf2cc43f08 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/DummyMainCreater.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/DummyMainCreater.ts @@ -175,7 +175,7 @@ export class DummyMainCreater { let superCls = method.getDeclaringArkClass().getSuperClass(); let methodInSuperCls = superCls?.getMethodWithName(method.getName()); if (methodInSuperCls) { - paramType = methodInSuperCls.getParameters().at(paramIdx)?.getType(); + paramType = methodInSuperCls.getParameters()[paramIdx]?.getType(); method = methodInSuperCls; } } diff --git a/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts b/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts index 08083474900627f2a07599c37994fc757e87c692..c670ead482c19720969b0afb7ca33035ab3fb9e1 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/IRInference.ts @@ -49,7 +49,7 @@ import { AliasClassSignature, BaseSignature, ClassSignature, - FieldSignature, + FieldSignature, FileSignature, MethodSignature, MethodSubSignature } from '../model/ArkSignature'; @@ -63,15 +63,14 @@ import { ArkArrayRef, ArkInstanceFieldRef, ArkParameterRef, - ArkStaticFieldRef, - GlobalRef + ArkStaticFieldRef } from '../base/Ref'; import { Value } from '../base/Value'; import { Constant } from '../base/Constant'; import { ANONYMOUS_CLASS_PREFIX, CALL_SIGNATURE_NAME, - DEFAULT_ARK_CLASS_NAME, + DEFAULT_ARK_CLASS_NAME, LEXICAL_ENV_NAME_PREFIX, NAME_DELIMITER, NAME_PREFIX, UNKNOWN_CLASS_NAME @@ -130,12 +129,17 @@ export class IRInference { } return 0; }); + arkClass.getAllHeritageClasses(); methods.forEach(arkMethod => TypeInference.inferTypeInMethod(arkMethod)); }); this.inferExportInfos(file); } public static inferStaticInvokeExpr(expr: ArkStaticInvokeExpr, arkMethod: ArkMethod): AbstractInvokeExpr { + const fileSignature = expr.getMethodSignature().getDeclaringClassSignature().getDeclaringFileSignature(); + if (fileSignature !== FileSignature.DEFAULT && fileSignature !== Builtin.BUILT_IN_CLASSES_FILE_SIGNATURE) { + return expr; + } const arkClass = arkMethod.getDeclaringArkClass(); const methodName = expr.getMethodSignature().getMethodSubSignature().getMethodName(); expr.getArgs().forEach(arg => TypeInference.inferValueType(arg, arkMethod)); @@ -252,10 +256,12 @@ export class IRInference { if (type instanceof FunctionType) { const methodSignature = type.getMethodSignature(); // because of last stmt is ArkReturnVoidStmt, the ArkInvokeStmt at -2 before ArkReturnVoidStmt. - const endIndex = -2; - const endStmt = arkMethod.getDeclaringArkFile().getScene().getMethod(methodSignature)?.getCfg()?.getStmts().at(endIndex); - if (endStmt instanceof ArkInvokeStmt) { - methodSignature.getMethodSubSignature().setReturnType(endStmt.getInvokeExpr().getType()); + const stmts = arkMethod.getDeclaringArkFile().getScene().getMethod(methodSignature)?.getCfg()?.getStmts(); + if (stmts) { + const endStmt = stmts[stmts.length - 2]; + if (endStmt instanceof ArkInvokeStmt) { + methodSignature.getMethodSubSignature().setReturnType(endStmt.getInvokeExpr().getType()); + } } expr.setMethodSignature(methodSignature); return expr; @@ -283,6 +289,11 @@ export class IRInference { private static inferBase(instance: ArkInstanceFieldRef | ArkInstanceInvokeExpr, arkMethod: ArkMethod): void { const base = instance.getBase(); if (base.getName() === THIS_NAME) { + const name = instance instanceof ArkInstanceFieldRef ? instance.getFieldName() : + instance.getMethodSignature().getMethodSubSignature().getMethodName(); + if (name.includes('.')) { + return; + } const declaringArkClass = arkMethod.getDeclaringArkClass(); if (declaringArkClass.isAnonymousClass()) { let newBase = this.inferThisLocal(arkMethod); @@ -293,14 +304,6 @@ export class IRInference { base.setType(new ClassType(declaringArkClass.getSignature(), declaringArkClass.getRealTypes())); } } else { - const value = arkMethod.getBody()?.getUsedGlobals()?.get(base.getName()); - if (value instanceof GlobalRef && !value.getRef()) { - const arkExport = ModelUtils.findGlobalRef(base.getName(), arkMethod); - if (arkExport instanceof Local) { - arkExport.getUsedStmts().push(...base.getUsedStmts()); - value.setRef(arkExport); - } - } this.inferLocal(instance.getBase(), arkMethod); } } @@ -445,17 +448,13 @@ export class IRInference { } private static inferInvokeExprWithArray(methodName: string, expr: AbstractInvokeExpr, baseType: ArrayType, scene: Scene): AbstractInvokeExpr | null { - if (methodName === Builtin.ITERATOR_FUNCTION) { - const returnType = expr.getMethodSignature().getMethodSubSignature().getReturnType(); - if (returnType instanceof ClassType && returnType.getClassSignature().getDeclaringFileSignature().getProjectName() === Builtin.DUMMY_PROJECT_NAME) { - expr.setRealGenericTypes([baseType.getBaseType()]); - return expr; - } - } else { - const arrayInterface = scene.getSdkGlobal(Builtin.ARRAY); - if (arrayInterface instanceof ArkClass) { - return this.inferInvokeExpr(expr, new ClassType(arrayInterface.getSignature(), [baseType.getBaseType()]), methodName, scene); - } + const arrayInterface = scene.getSdkGlobal(Builtin.ARRAY); + if (arrayInterface instanceof ArkClass) { + return this.inferInvokeExpr(expr, new ClassType(arrayInterface.getSignature(), [baseType.getBaseType()]), methodName, scene); + } else if (methodName === Builtin.ITERATOR_FUNCTION) { + expr.getMethodSignature().getMethodSubSignature().setReturnType(Builtin.ITERATOR_CLASS_TYPE); + expr.setRealGenericTypes([baseType.getBaseType()]); + return expr; } return null; } @@ -498,7 +497,7 @@ export class IRInference { const methodSignature = method.matchMethodSignature(expr.getArgs()); TypeInference.inferSignatureReturnType(methodSignature, method); expr.setMethodSignature(this.replaceMethodSignature(expr.getMethodSignature(), methodSignature)); - expr.setRealGenericTypes(IRInference.getRealTypes(method, declaredClass, baseType)); + expr.setRealGenericTypes(IRInference.getRealTypes(expr, declaredClass, baseType, method)); if (method.isStatic() && expr instanceof ArkInstanceInvokeExpr) { return new ArkStaticInvokeExpr(methodSignature, expr.getArgs(), expr.getRealGenericTypes()); } @@ -527,25 +526,33 @@ export class IRInference { const subSignature = new MethodSubSignature(methodName, [], new ClassType(baseType.getClassSignature())); expr.setMethodSignature(new MethodSignature(baseType.getClassSignature(), subSignature)); return expr; - } else if (methodName === Builtin.ITERATOR_NEXT) { - //sdk隐式构造 - const returnType = expr.getMethodSignature().getMethodSubSignature().getReturnType(); - if (returnType instanceof ClassType && returnType.getClassSignature().getDeclaringFileSignature().getProjectName() === Builtin.DUMMY_PROJECT_NAME) { - returnType.setRealGenericTypes(baseType.getRealGenericTypes()); - return expr; - } + } else if (methodName === Builtin.ITERATOR_NEXT && + baseType.getClassSignature().getDeclaringFileSignature().getProjectName() === Builtin.DUMMY_PROJECT_NAME) { + expr.getMethodSignature().getMethodSubSignature().setReturnType(Builtin.ITERATOR_RESULT_CLASS_TYPE); + expr.setRealGenericTypes(baseType.getRealGenericTypes()); + return expr; } return null; } - private static getRealTypes(method: ArkMethod, declaredClass: ArkClass | null, baseType: ClassType): Type[] | undefined { + private static getRealTypes(expr: AbstractInvokeExpr, declaredClass: ArkClass | null, baseType: ClassType, method: ArkMethod): Type[] | undefined { let realTypes; - if (method.getDeclaringArkClass() === declaredClass) { - realTypes = baseType.getRealGenericTypes(); - } else if (declaredClass?.getRealTypes()) { - realTypes = declaredClass?.getRealTypes(); + const tmp: Type[] = []; + if (method.getGenericTypes()) { + expr.getMethodSignature().getMethodSubSignature().getParameters() + .filter(p => !p.getName().startsWith(LEXICAL_ENV_NAME_PREFIX)) + .forEach((p, i) => { + if (TypeInference.checkType(p.getType(), t => t instanceof GenericType)) { + tmp.push(expr.getArg(i).getType()); + } + }); + } + if (tmp.length > 0) { + realTypes = tmp; } else if (declaredClass?.hasComponentDecorator()) { realTypes = [new ClassType(declaredClass?.getSignature())]; + } else { + realTypes = baseType.getRealGenericTypes() ?? declaredClass?.getRealTypes(); } return realTypes; } @@ -618,23 +625,13 @@ export class IRInference { } const fieldName = ref.getFieldName().replace(/[\"|\']/g, ''); const propertyAndType = TypeInference.inferFieldType(baseType, fieldName, arkClass); - let propertyType = propertyAndType?.[1]; - if (!propertyType || propertyType instanceof UnknownType) { - const newType = TypeInference.inferBaseType(fieldName, arkClass); - if (newType) { - propertyType = newType; - } - } else if (TypeInference.isUnclearType(propertyType)) { - const newType = TypeInference.inferUnclearedType(propertyType, arkClass); - if (newType) { - propertyType = newType; - } - } + let propertyType = IRInference.repairType(propertyAndType?.[1], fieldName, arkClass); let staticFlag: boolean; let signature: BaseSignature; if (baseType instanceof ClassType) { const property = propertyAndType?.[0]; - if (property instanceof ArkField && property.getCategory() !== FieldCategory.ENUM_MEMBER) { + if (property instanceof ArkField && property.getCategory() !== FieldCategory.ENUM_MEMBER && + !(property.getType() instanceof GenericType)) { return property.getSignature(); } staticFlag = @@ -650,6 +647,21 @@ export class IRInference { return new FieldSignature(fieldName, signature, propertyType ?? ref.getType(), staticFlag); } + private static repairType(propertyType: Type | undefined, fieldName: string, arkClass: ArkClass): Type | undefined { + if (!propertyType || propertyType instanceof UnknownType) { + const newType = TypeInference.inferBaseType(fieldName, arkClass); + if (newType) { + propertyType = newType; + } + } else if (TypeInference.isUnclearType(propertyType)) { + const newType = TypeInference.inferUnclearedType(propertyType, arkClass); + if (newType) { + propertyType = newType; + } + } + return propertyType; + } + public static inferAnonymousClass(anon: ArkClass | null, declaredSignature: ClassSignature, set: Set = new Set()): void { if (!anon) { return; @@ -686,7 +698,7 @@ export class IRInference { private static assignAnonMethod(anonMethod: ArkMethod | null, declaredMethod: ArkMethod | null): void { if (declaredMethod && anonMethod) { - anonMethod.setImplementationSignature(declaredMethod.matchMethodSignature(anonMethod.getSubSignature().getParameters())); + anonMethod.setDeclareSignatures(declaredMethod.matchMethodSignature(anonMethod.getSubSignature().getParameters())); } } @@ -698,7 +710,8 @@ export class IRInference { } const type = property.getSignature().getType(); - const lastStmt = anonField.getInitializer().at(-1); + const fieldInitializer = anonField.getInitializer(); + const lastStmt = fieldInitializer[fieldInitializer.length - 1]; if (lastStmt instanceof ArkAssignStmt) { const rightType = lastStmt.getRightOp().getType(); if (type instanceof ClassType) { @@ -815,7 +828,8 @@ export class IRInference { public static inferParameterRef(ref: ArkParameterRef, arkMethod: ArkMethod): AbstractRef { const paramType = ref.getType(); if (paramType instanceof UnknownType || paramType instanceof UnclearReferenceType) { - const type1 = arkMethod.getSignature().getMethodSubSignature().getParameters()[ref.getIndex()]?.getType(); + const signature = arkMethod.getDeclareSignatures()?.[0] ?? arkMethod.getSignature(); + const type1 = signature.getMethodSubSignature().getParameters()[ref.getIndex()]?.getType(); if (!TypeInference.isUnclearType(type1)) { ref.setType(type1); return ref; diff --git a/ets2panda/linter/arkanalyzer/src/core/common/ModelUtils.ts b/ets2panda/linter/arkanalyzer/src/core/common/ModelUtils.ts index 7b90129608f4f99a927f46f22ad6f4491e4f6572..ae079bea04211cd775ad598c981129272d5b01b4 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/ModelUtils.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/ModelUtils.ts @@ -37,14 +37,7 @@ import path from 'path'; import { Sdk } from '../../Config'; import { ALL, DEFAULT, THIS_NAME } from './TSConst'; import { buildDefaultExportInfo } from '../model/builder/ArkExportBuilder'; -import { - AnnotationNamespaceType, - ClassType, - FunctionType, - Type, - UnclearReferenceType, - UnknownType -} from '../base/Type'; +import { AnnotationNamespaceType, ClassType, FunctionType, Type, UnclearReferenceType, UnknownType } from '../base/Type'; import { Scene } from '../../Scene'; import { DEFAULT_ARK_CLASS_NAME, DEFAULT_ARK_METHOD_NAME, NAME_DELIMITER, TEMP_LOCAL_PREFIX } from './Const'; import { EMPTY_STRING } from './ValueUtil'; @@ -56,6 +49,14 @@ import { SdkUtils } from './SdkUtils'; export class ModelUtils { public static implicitArkUIBuilderMethods: Set = new Set(); + /* + * Set static field to be null, then all related objects could be freed by GC. + * Static field implicitArkUIBuilderMethods is only used during method body building, the dispose method should be called after build all body. + */ + public static dispose(): void { + this.implicitArkUIBuilderMethods.clear(); + } + public static getMethodSignatureFromArkClass(arkClass: ArkClass, methodName: string): MethodSignature | null { for (const arkMethod of arkClass.getMethods()) { if (arkMethod.getName() === methodName) { @@ -570,8 +571,7 @@ export function getArkFile(im: FromInfo): ArkFile | null | undefined { export function findExportInfo(fromInfo: FromInfo): ExportInfo | null { let file = getArkFile(fromInfo); if (!file) { - logger.warn(`${fromInfo.getOriginName()} ${fromInfo.getFrom()} file not found: - ${fromInfo.getDeclaringArkFile()?.getFileSignature()?.toString()}`); + logger.warn(`${fromInfo.getOriginName()} ${fromInfo.getFrom()} file not found: ${fromInfo.getDeclaringArkFile()?.getFileSignature()?.toString()}`); return null; } if (fileSignatureCompare(file.getFileSignature(), fromInfo.getDeclaringArkFile().getFileSignature())) { @@ -623,8 +623,8 @@ export function findArkExport(exportInfo: ExportInfo | undefined): ArkExport | n if (arkExport) { exportInfo.setArkExport(arkExport); } else { - logger.warn(`${exportInfo.getExportClauseName()} get arkExport fail from ${exportInfo.getFrom()} at - ${exportInfo.getDeclaringArkFile().getFileSignature().toString()}`); + const file = exportInfo.getDeclaringArkFile().getFileSignature().toString(); + logger.warn(`${exportInfo.getExportClauseName()} get arkExport fail from ${exportInfo.getFrom()} at ${file}`); } return arkExport || null; } diff --git a/ets2panda/linter/arkanalyzer/src/core/common/SdkUtils.ts b/ets2panda/linter/arkanalyzer/src/core/common/SdkUtils.ts index 84f185987813e6866c2bf4fc398e9e2c9a0d20d1..aa3b7fd4213ce758f148f3c8d346d7302402718f 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/SdkUtils.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/SdkUtils.ts @@ -20,18 +20,80 @@ import { GLOBAL_THIS_NAME, THIS_NAME } from './TSConst'; import { TEMP_LOCAL_PREFIX } from './Const'; import { ArkClass, ClassCategory } from '../model/ArkClass'; import { LocalSignature } from '../model/ArkSignature'; -import { ModelUtils } from './ModelUtils'; import { Local } from '../base/Local'; import { ArkMethod } from '../model/ArkMethod'; import path from 'path'; import { ClassType } from '../base/Type'; import { AbstractFieldRef } from '../base/Ref'; import { ArkNamespace } from '../model/ArkNamespace'; -import { TypeInference } from './TypeInference'; +import Logger, { LOG_MODULE_TYPE } from '../../utils/logger'; +import { Sdk } from '../../Config'; +import ts from 'ohos-typescript'; +import fs from 'fs'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.ARKANALYZER, 'SdkUtils'); export class SdkUtils { + private static esVersion: string = 'ES2017'; + private static esVersionMap: Map = new Map([ + ['ES2017', 'lib.es2020.d.ts'], + ['ES2021', 'lib.es2021.d.ts'] + ]); private static sdkImportMap: Map = new Map(); + public static BUILT_IN_NAME = 'built-in'; + private static BUILT_IN_PATH = 'node_modules/ohos-typescript/lib'; + public static BUILT_IN_SDK: Sdk = { + moduleName: '', + name: `${SdkUtils.BUILT_IN_NAME}`, + path: '' + }; + + public static setEsVersion(buildProfile: any): void { + const accessChain = 'buildOption.arkOptions.tscConfig.targetESVersion'; + const version = accessChain.split('.').reduce((acc, key) => acc?.[key], buildProfile); + if (version && this.esVersionMap.has(version)) { + this.esVersion = version; + } + } + + public static fetchBuiltInFiles(): string[] { + let builtInPath = this.BUILT_IN_PATH; + try { + // If arkanalyzer is used as dependency by other project, the base directory should be the module path. + const moduleRoot = path.dirname(path.dirname(require.resolve('ohos-typescript'))); + builtInPath = path.join(moduleRoot, 'lib'); + logger.debug(`arkanalyzer is used as dependency, so using builtin sdk file in ${builtInPath}.`); + } catch { + logger.debug(`use builtin sdk file in ${builtInPath}.`); + } + const filePath = path.resolve(builtInPath, this.esVersionMap.get(this.esVersion) ?? ''); + this.BUILT_IN_SDK.path = path.resolve(builtInPath); + if (!fs.existsSync(filePath)) { + logger.error(`built in directory ${filePath} is not exist, please check!`); + return []; + } + const result = new Set(); + this.dfsFiles(filePath, result); + return Array.from(result); + } + + private static dfsFiles(filePath: string, files: Set): void { + const sourceFile = ts.createSourceFile(filePath, fs.readFileSync(filePath, 'utf8'), ts.ScriptTarget.Latest); + const references = sourceFile.libReferenceDirectives; + references.forEach(ref => { + this.dfsFiles(path.join(path.dirname(filePath), `lib.${ref.fileName}.d.ts`), files); + }); + files.add(filePath); + } + + /* + * Set static field to be null, then all related objects could be freed by GC. + * Class SdkUtils is only internally used by ArkAnalyzer type inference, the dispose method should be called at the end of type inference. + */ + public static dispose(): void { + this.sdkImportMap.clear(); + } public static buildSdkImportMap(file: ArkFile): void { const fileName = path.basename(file.getName()); @@ -44,7 +106,7 @@ export class SdkUtils { return this.sdkImportMap.get(from); } - public static buildGlobalMap(file: ArkFile, globalMap: Map): void { + public static loadGlobalAPI(file: ArkFile, globalMap: Map): void { const isGlobalPath = file .getScene() .getOptions() @@ -52,20 +114,59 @@ export class SdkUtils { if (!isGlobalPath) { return; } - ModelUtils.getAllClassesInFile(file).forEach(cls => { + file.getClasses().forEach(cls => { if (!cls.isAnonymousClass() && !cls.isDefaultArkClass()) { - SdkUtils.loadClass(globalMap, cls); + this.loadAPI(cls, globalMap); } if (cls.isDefaultArkClass()) { cls.getMethods() .filter(mtd => !mtd.isDefaultArkMethod() && !mtd.isAnonymousMethod()) - .forEach(mtd => globalMap.set(mtd.getName(), mtd)); + .forEach(mtd => this.loadAPI(mtd, globalMap)); } }); - const defaultArkMethod = file.getDefaultClass().getDefaultArkMethod(); - if (defaultArkMethod) { - TypeInference.inferTypeInMethod(defaultArkMethod); + file.getDefaultClass().getDefaultArkMethod() + ?.getBody() + ?.getAliasTypeMap() + ?.forEach(a => this.loadAPI(a[0], globalMap, true)); + file.getNamespaces().forEach(ns => this.loadAPI(ns, globalMap)); + } + + public static mergeGlobalAPI(file: ArkFile, globalMap: Map): void { + const isGlobalPath = file + .getScene() + .getOptions() + .sdkGlobalFolders?.find(x => file.getFilePath().includes(path.sep + x + path.sep)); + if (!isGlobalPath) { + return; } + file.getClasses().forEach(cls => { + if (!cls.isAnonymousClass() && !cls.isDefaultArkClass()) { + this.loadClass(globalMap, cls); + } + }); + } + + public static loadAPI(api: ArkExport, globalMap: Map, override: boolean = false): void { + const old = globalMap.get(api.getName()); + if (!old) { + globalMap.set(api.getName(), api); + } else if (override) { + logger.trace(`${old.getSignature()} is override`); + globalMap.set(api.getName(), api); + } else { + logger.trace(`duplicated api: ${api.getSignature()}`); + } + } + + public static postInferredSdk(file: ArkFile, globalMap: Map): void { + const isGlobalPath = file + .getScene() + .getOptions() + .sdkGlobalFolders?.find(x => file.getFilePath().includes(path.sep + x + path.sep)); + if (!isGlobalPath) { + return; + } + const defaultArkMethod = file.getDefaultClass().getDefaultArkMethod(); defaultArkMethod ?.getBody() ?.getLocals() @@ -75,25 +176,22 @@ export class SdkUtils { this.loadGlobalLocal(local, defaultArkMethod, globalMap); } }); - defaultArkMethod - ?.getBody() - ?.getAliasTypeMap() - ?.forEach(a => globalMap.set(a[0].getName(), a[0])); - ModelUtils.getAllNamespacesInFile(file).forEach(ns => globalMap.set(ns.getName(), ns)); } private static loadClass(globalMap: Map, cls: ArkClass): void { const old = globalMap.get(cls.getName()); - if (old instanceof ArkClass) { - if (old.getCategory() === ClassCategory.CLASS) { - this.copyMethod(cls, old); + if (cls === old) { + return; + } else if (old instanceof ArkClass && old.getDeclaringArkFile().getProjectName() === cls.getDeclaringArkFile().getProjectName()) { + if (old.getCategory() === ClassCategory.CLASS || old.getCategory() === ClassCategory.INTERFACE) { + this.copyMembers(cls, old); } else { - this.copyMethod(old, cls); + this.copyMembers(old, cls); globalMap.delete(cls.getName()); - globalMap.set(cls.getName(), cls); + this.loadAPI(cls, globalMap, true); } - } else if (!old) { - globalMap.set(cls.getName(), cls); + } else { + this.loadAPI(cls, globalMap, true); } } @@ -105,29 +203,25 @@ export class SdkUtils { const instance = globalMap.get(name + 'Interface'); const attr = globalMap.get(name + COMPONENT_ATTRIBUTE); if (attr instanceof ArkClass && instance instanceof ArkClass) { - instance - .getMethods() - .filter(m => !attr.getMethodWithName(m.getName())) - .forEach(m => attr.addMethod(m)); + this.copyMembers(instance, attr); globalMap.set(name, attr); return; } } const old = globalMap.get(name); - if (!old) { - globalMap.set(name, local); - } else if (old instanceof ArkClass && local.getType() instanceof ClassType) { - const localConstructor = scene.getClass((local.getType() as ClassType).getClassSignature()); - if (localConstructor) { - localConstructor - .getMethods() - .filter(m => !old.getMethodWithName(m.getName())) - .forEach(m => old.addMethod(m)); + if (old instanceof ArkClass && local.getType() instanceof ClassType) { + const localConstructor = globalMap.get((local.getType() as ClassType).getClassSignature().getClassName()); + if (localConstructor instanceof ArkClass) { + this.copyMembers(localConstructor, old); + } else { + this.loadAPI(local, globalMap, true); } + } else { + this.loadAPI(local, globalMap, true); } } - private static copyMethod(from: ArkClass, to: ArkClass): void { + private static copyMembers(from: ArkClass, to: ArkClass): void { from.getMethods().forEach(method => { const dist = method.isStatic() ? to.getStaticMethodWithName(method.getName()) : to.getMethodWithName(method.getName()); const distSignatures = dist?.getDeclareSignatures(); @@ -137,6 +231,12 @@ export class SdkUtils { to.addMethod(method); } }); + from.getFields().forEach(field => { + const dist = field.isStatic() ? to.getStaticFieldWithName(field.getName()) : to.getFieldWithName(field.getName()); + if (!dist) { + to.addField(field); + } + }); } public static computeGlobalThis(leftOp: AbstractFieldRef, arkMethod: ArkMethod): void { diff --git a/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts b/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts index e754272cbfd07f2cd1290ef386b91ac55e12fa2a..a2a2b250674cb07043f273cae8c67ce6f403a228 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/TypeInference.ts @@ -16,7 +16,14 @@ import Logger, { LOG_MODULE_TYPE } from '../../utils/logger'; import { AbstractExpr, ArkInstanceInvokeExpr, ArkPtrInvokeExpr, ArkStaticInvokeExpr } from '../base/Expr'; import { Local } from '../base/Local'; -import { AbstractFieldRef, AbstractRef, ArkArrayRef, ArkInstanceFieldRef, ArkParameterRef, ArkStaticFieldRef } from '../base/Ref'; +import { + AbstractFieldRef, + AbstractRef, + ArkArrayRef, + ArkInstanceFieldRef, + ArkParameterRef, + ArkStaticFieldRef, GlobalRef +} from '../base/Ref'; import { ArkAliasTypeDefineStmt, ArkAssignStmt, ArkReturnStmt, Stmt } from '../base/Stmt'; import { AliasType, @@ -54,7 +61,7 @@ import { ANY_KEYWORD, BIGINT_KEYWORD, BOOLEAN_KEYWORD, - CONSTRUCTOR_NAME, + CONSTRUCTOR_NAME, DEFAULT, GLOBAL_THIS_NAME, NEVER_KEYWORD, NULL_KEYWORD, @@ -157,7 +164,7 @@ export class TypeInference { type = leftOpType; } } else if (leftOpType instanceof AnnotationNamespaceType) { - type = this.inferUnclearRefName(leftOpType.getOriginType(), declaringArkClass); + type = this.inferBaseType(leftOpType.getOriginType(), declaringArkClass); } else if (leftOpType instanceof UnclearReferenceType) { type = this.inferUnclearRefType(leftOpType, declaringArkClass); } @@ -185,6 +192,15 @@ export class TypeInference { signatures.forEach(s => this.inferSignatureReturnType(s, arkMethod)); return; } + body.getUsedGlobals()?.forEach((value, key) => { + if (value instanceof GlobalRef && !value.getRef()) { + const arkExport = ModelUtils.findGlobalRef(key, arkMethod); + if (arkExport instanceof Local) { + arkExport.getUsedStmts().push(...value.getUsedStmts()); + value.setRef(arkExport); + } + } + }); const cfg = body.getCfg(); for (const block of cfg.getBlocks()) { for (const stmt of block.getStmts()) { @@ -387,7 +403,8 @@ export class TypeInference { public static isUnclearType(type: Type | null | undefined): boolean { // TODO: For UnionType, IntersectionType and TupleType, it should recurse check every item of them. - if (!type || type instanceof UnknownType || type instanceof UnclearReferenceType || type instanceof NullType || type instanceof UndefinedType) { + if (!type || type instanceof UnknownType || type instanceof UnclearReferenceType || type instanceof NullType || + type instanceof UndefinedType || type instanceof GenericType) { return true; } else if ( type instanceof ClassType && @@ -398,10 +415,10 @@ export class TypeInference { ) { return true; } else if (type instanceof UnionType || type instanceof IntersectionType || type instanceof TupleType) { - return !!type.getTypes().find(t => this.hasUnclearReferenceType(t)); + return !!type.getTypes().find(t => this.checkType(t, e => e instanceof UnclearReferenceType)); } else if (type instanceof ArrayType) { const baseType = type.getBaseType(); - return this.hasUnclearReferenceType(baseType) || baseType instanceof GenericType; + return this.checkType(baseType, t => t instanceof UnclearReferenceType) || baseType instanceof GenericType; } else if (type instanceof AliasType) { return this.isUnclearType(type.getOriginalType()); } else if (type instanceof KeyofTypeExpr) { @@ -412,25 +429,29 @@ export class TypeInference { return false; } - // This is the temporal function to check unclearReferenceType recursively and can be removed after typeInfer supports multiple candidate types. - private static hasUnclearReferenceType(type: Type, visited: Set = new Set()): boolean { + // This is the temporal function to check Type recursively and can be removed after typeInfer supports multiple candidate types. + public static checkType(type: Type, + check: (t: Type) => boolean, + visited: Set = new Set()): boolean { if (visited.has(type)) { return false; } else { visited.add(type); } - if (type instanceof UnclearReferenceType) { + if (check(type)) { return true; + } else if (type instanceof ClassType) { + return !!type.getRealGenericTypes()?.find(t => this.checkType(t, check, visited)); } else if (type instanceof UnionType || type instanceof IntersectionType || type instanceof TupleType) { - return !!type.getTypes().find(t => this.hasUnclearReferenceType(t, visited)); + return !!type.getTypes().find(t => this.checkType(t, check, visited)); } else if (type instanceof ArrayType) { - return this.hasUnclearReferenceType(type.getBaseType(), visited); + return this.checkType(type.getBaseType(), check, visited); } else if (type instanceof AliasType) { - return this.hasUnclearReferenceType(type.getOriginalType(), visited); + return this.checkType(type.getOriginalType(), check, visited); } else if (type instanceof KeyofTypeExpr) { - return this.hasUnclearReferenceType(type.getOpType(), visited); + return this.checkType(type.getOpType(), check, visited); } else if (type instanceof TypeQueryExpr) { - return this.hasUnclearReferenceType(type.getType(), visited); + return this.checkType(type.getType(), check, visited); } return false; } @@ -488,7 +509,7 @@ export class TypeInference { return value.getType(); } - private static inferParameterType(param: MethodParameter, arkMethod: ArkMethod): void { + public static inferParameterType(param: MethodParameter, arkMethod: ArkMethod): void { let pType = param.getType(); const arkClass = arkMethod.getDeclaringArkClass(); let type; @@ -697,13 +718,14 @@ export class TypeInference { if (property instanceof ArkField) { if (arkClass.getCategory() === ClassCategory.ENUM) { let constant; - const lastStmt = property.getInitializer().at(-1); + const propertyInitializer = property.getInitializer(); + const lastStmt = propertyInitializer[propertyInitializer.length - 1]; if (lastStmt instanceof ArkAssignStmt && lastStmt.getRightOp() instanceof Constant) { constant = lastStmt.getRightOp() as Constant; } propertyType = new EnumValueType(property.getSignature(), constant); } else { - propertyType = property.getType(); + propertyType = this.replaceTypeWithReal(property.getType(), baseType.getRealGenericTypes()); } } else if (property) { propertyType = this.parseArkExport2Type(property); @@ -728,6 +750,8 @@ export class TypeInference { public static inferBaseType(baseName: string, arkClass: ArkClass): Type | null { if (SUPER_NAME === baseName) { return this.parseArkExport2Type(arkClass.getSuperClass()); + } else if (DEFAULT === baseName) { + return this.parseArkExport2Type(arkClass.getDeclaringArkFile().getExportInfoBy(DEFAULT)?.getArkExport()); } const field = ModelUtils.getDefaultClass(arkClass)?.getDefaultArkMethod()?.getBody()?.getLocals()?.get(baseName); if (field && !this.isUnclearType(field.getType())) { @@ -750,18 +774,21 @@ export class TypeInference { ModelUtils.getClassWithName(typeName, arkClass) ?? ModelUtils.getDefaultClass(arkClass)?.getDefaultArkMethod()?.getBody()?.getAliasTypeByName(typeName) ?? ModelUtils.getArkExportInImportInfoWithName(typeName, arkClass.getDeclaringArkFile()); - if (arkExport instanceof ArkClass || arkExport instanceof AliasType) { - return this.parseArkExport2Type(arkExport); - } - if (!arkClass.getDeclaringArkFile().getImportInfoBy(typeName)) { + if (!arkExport && !arkClass.getDeclaringArkFile().getImportInfoBy(typeName)) { arkExport = arkClass.getDeclaringArkFile().getScene().getSdkGlobal(typeName); } - if (arkExport instanceof ArkClass || arkExport instanceof AliasType) { - return this.parseArkExport2Type(arkExport); + const type = this.parseArkExport2Type(arkExport); + if (type instanceof ClassType || type instanceof AliasType) { + return type; } return null; } + public static getTypeByGlobalName(globalName: string, arkMethod: ArkMethod): Type | null { + const arkExport: ArkExport | null = arkMethod.getDeclaringArkFile().getScene().getSdkGlobal(globalName); + return this.parseArkExport2Type(arkExport); + } + public static inferRealGenericTypes(realTypes: Type[] | undefined, arkClass: ArkClass): void { if (!realTypes) { return; @@ -860,12 +887,14 @@ export class TypeInference { .getParameters() .filter(p => !p.getName().startsWith(LEXICAL_ENV_NAME_PREFIX)) .forEach((p, i) => { - let type = params?.[i]?.getType(); - if (type instanceof GenericType && realTypes) { - type = realTypes?.[type.getIndex()]; - } - if (type) { - p.setType(type); + if (this.isUnclearType(p.getType())) { + let type = params?.[i]?.getType(); + if (type instanceof GenericType && realTypes) { + type = realTypes?.[type.getIndex()]; + } + if (type) { + p.setType(type); + } } }); } @@ -876,7 +905,7 @@ export class TypeInference { } let returnType: Type | undefined = arkMethod.getSignature().getType(); if (returnType instanceof ClassType && returnType.getClassSignature().getClassName() === PROMISE) { - returnType = returnType.getRealGenericTypes()?.at(0); + returnType = returnType.getRealGenericTypes()?.[0]; } if (returnType) { IRInference.inferRightWithSdkType(returnType, stmt.getOp().getType(), arkMethod.getDeclaringArkClass()); diff --git a/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts b/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts index 1731b701b04d71d60c4e12b93931b2c9ec0547aa..8a29e565b84e8db412f6ef951fca7c0046516794 100644 --- a/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts +++ b/ets2panda/linter/arkanalyzer/src/core/common/ValueUtil.ts @@ -21,6 +21,14 @@ export class ValueUtil { private static readonly NumberConstantCache: Map = new Map(); public static readonly EMPTY_STRING_CONSTANT = new StringConstant(EMPTY_STRING); + /* + * Set static field to be null, then all related objects could be freed by GC. + * Class SdkUtils is only internally used by ArkAnalyzer, the dispose method should be called by users themselves before drop Scene. + */ + public static dispose(): void { + this.NumberConstantCache.clear(); + } + public static getOrCreateNumberConst(n: number): Constant { let constant = this.NumberConstantCache.get(n); if (constant === undefined) { diff --git a/ets2panda/linter/arkanalyzer/src/core/dataflow/DataflowSolver.ts b/ets2panda/linter/arkanalyzer/src/core/dataflow/DataflowSolver.ts index 523dd9a41b17104bc1b850c060e8a50fd796ba03..325fa23634c05a967cc4ce7192c623e4351f0926 100644 --- a/ets2panda/linter/arkanalyzer/src/core/dataflow/DataflowSolver.ts +++ b/ets2panda/linter/arkanalyzer/src/core/dataflow/DataflowSolver.ts @@ -24,6 +24,7 @@ import { CallGraph } from '../../callgraph/model/CallGraph'; import { ClassHierarchyAnalysis } from '../../callgraph/algorithm/ClassHierarchyAnalysis'; import { addCfg2Stmt } from '../../utils/entryMethodUtils'; import { getRecallMethodInParam } from './Util'; +import { CallGraphBuilder } from '../../callgraph/model/builder/CallGraphBuilder'; /* this program is roughly an implementation of the paper: Practical Extensions to the IFDS Algorithm. @@ -88,7 +89,7 @@ export abstract class DataflowSolver { // build CHA let cg = new CallGraph(this.scene); - this.CHA = new ClassHierarchyAnalysis(this.scene, cg); + this.CHA = new ClassHierarchyAnalysis(this.scene, cg, new CallGraphBuilder(cg, this.scene)); this.buildStmtMapInClass(); this.setCfg4AllStmt(); return; diff --git a/ets2panda/linter/arkanalyzer/src/core/graph/Scc.ts b/ets2panda/linter/arkanalyzer/src/core/graph/Scc.ts index aeb568012db582c7a1cd860edb59b2f22820a163..ccafdd7067b76d4562d6f31eb43cb45d698584ec 100644 --- a/ets2panda/linter/arkanalyzer/src/core/graph/Scc.ts +++ b/ets2panda/linter/arkanalyzer/src/core/graph/Scc.ts @@ -173,7 +173,7 @@ export class SCCDetection> { if (this.getRep(v) === v) { this.setInSCC(v); while (this._S.length > 0) { - let w = this._S.at(this._S.length - 1)!; + let w = this._S[this._S.length - 1]!; if (this._D.get(w)! <= this._D.get(v)!) { break; } else { diff --git a/ets2panda/linter/arkanalyzer/src/core/graph/builder/CfgBuilder.ts b/ets2panda/linter/arkanalyzer/src/core/graph/builder/CfgBuilder.ts index 5cd44402ec52488fb5bef3750f8b7af54b0c2f3e..478d0a7121bc5a7753f791936c3e07bbef8e7df2 100644 --- a/ets2panda/linter/arkanalyzer/src/core/graph/builder/CfgBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/core/graph/builder/CfgBuilder.ts @@ -32,6 +32,7 @@ import { ConditionBuilder } from './ConditionBuilder'; import { TrapBuilder } from './TrapBuilder'; import { CONSTRUCTOR_NAME, PROMISE } from '../../common/TSConst'; import { ModifierType } from '../../model/ArkBaseModel'; +import { ParameterDeclaration } from 'ohos-typescript'; class StatementBuilder { type: string; @@ -524,7 +525,7 @@ export class CfgBuilder { this.scopes.push(scope); for (let i = 0; i < nodes.length; i++) { let c = nodes[i]; - if (ts.isVariableStatement(c) || ts.isExpressionStatement(c) || ts.isThrowStatement(c) || ts.isTypeAliasDeclaration(c)) { + if (ts.isVariableStatement(c) || ts.isExpressionStatement(c) || ts.isThrowStatement(c) || ts.isTypeAliasDeclaration(c) || ts.isParameter(c)) { let s = new StatementBuilder('statement', c.getText(this.sourceFile), c, scope.id); this.judgeLastType(s, lastStatement); lastStatement = s; @@ -677,6 +678,9 @@ export class CfgBuilder { for (let i = stmt.nexts.length - 1; i >= 0; i--) { stmtQueue.push(stmt.nexts[i]); } + if (stmt.afterSwitch && stmt.afterSwitch.lasts.size === 0) { + stmtQueue.push(stmt.afterSwitch); + } } else if (stmt instanceof TryStatementBuilder) { if (stmt.finallyStatement) { stmtQueue.push(stmt.finallyStatement); @@ -956,6 +960,16 @@ export class CfgBuilder { this.exit.lasts = new Set([s]); } + private getParamPropertyNodes(constructorParams: ts.NodeArray): ts.Node[] { + let stmts: ts.Node[] = []; + constructorParams.forEach(parameter => { + if (parameter.modifiers !== undefined) { + stmts.push(parameter); + } + }); + return stmts; + } + buildCfgBuilder(): void { let stmts: ts.Node[] = []; if (ts.isSourceFile(this.astRoot)) { @@ -969,11 +983,7 @@ export class CfgBuilder { ts.isFunctionExpression(this.astRoot) || ts.isClassStaticBlockDeclaration(this.astRoot) ) { - if (this.astRoot.body) { - stmts = [...this.astRoot.body.statements]; - } else { - this.emptyBody = true; - } + this.astRoot.body ? stmts = [...this.astRoot.body.statements] : this.emptyBody = true; } else if (ts.isArrowFunction(this.astRoot)) { if (ts.isBlock(this.astRoot.body)) { stmts = [...this.astRoot.body.statements]; @@ -988,6 +998,10 @@ export class CfgBuilder { } else if (ts.isModuleDeclaration(this.astRoot) && ts.isModuleBlock(this.astRoot.body!)) { stmts = [...this.astRoot.body.statements]; } + // For constructor, add parameter property node to stmts which can be used when build body + if (ts.isConstructorDeclaration(this.astRoot)) { + stmts = [...this.getParamPropertyNodes(this.astRoot.parameters), ...stmts]; + } if (!ModelUtils.isArkUIBuilderMethod(this.declaringMethod)) { this.walkAST(this.entry, this.exit, stmts); } else { @@ -996,6 +1010,7 @@ export class CfgBuilder { if (ts.isArrowFunction(this.astRoot) && !ts.isBlock(this.astRoot.body)) { this.buildStatementBuilder4ArrowFunction(this.astRoot.body); } + this.addReturnInEmptyMethod(); this.deleteExit(); this.CfgBuilder2Array(this.entry); diff --git a/ets2panda/linter/arkanalyzer/src/core/graph/builder/TrapBuilder.ts b/ets2panda/linter/arkanalyzer/src/core/graph/builder/TrapBuilder.ts index 160df9fdc0420bd843f79edbbe7f43552c9e3699..9094994dc5d4099e379f3cd032f84eb9ad448c5a 100644 --- a/ets2panda/linter/arkanalyzer/src/core/graph/builder/TrapBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/core/graph/builder/TrapBuilder.ts @@ -19,7 +19,15 @@ import { Trap } from '../../base/Trap'; import { ArkCaughtExceptionRef } from '../../base/Ref'; import { UnknownType } from '../../base/Type'; import { FullPosition } from '../../base/Position'; -import { ArkAssignStmt, ArkIfStmt, ArkInvokeStmt, ArkReturnStmt, ArkReturnVoidStmt, ArkThrowStmt, Stmt } from '../../base/Stmt'; +import { + ArkAssignStmt, + ArkIfStmt, + ArkInvokeStmt, + ArkReturnStmt, + ArkReturnVoidStmt, + ArkThrowStmt, + Stmt, +} from '../../base/Stmt'; import { BlockBuilder, TryStatementBuilder } from './CfgBuilder'; import Logger, { LOG_MODULE_TYPE } from '../../../utils/logger'; @@ -217,16 +225,17 @@ export class TrapBuilder { bfsBlocks.push(currBlock); const childList = currBlockBuilder.nexts; - if (childList.length === 0 || (childList.length !== 0 && childList[0] === endBlockBuilder)) { - if (childList[0] === endBlockBuilder) { - tailBlocks.push(currBlock); - continue; - } - } if (childList.length !== 0) { for (const child of childList) { - queue.push(child); + // A tail block's successor may be within the traversal range + if (child === endBlockBuilder) { + tailBlocks.push(currBlock); + } else { + queue.push(child); + } } + } else { + tailBlocks.push(currBlock); } } return { bfsBlocks, tailBlocks }; @@ -247,19 +256,16 @@ export class TrapBuilder { copyFinallyBfsBlocks[0].getPredecessors().splice(0, finallyPredecessorsCnt); const throwStmt = new ArkThrowStmt(exceptionValue); let copyFinallyTailBlocks = copyFinallyBfsBlocks.splice(copyFinallyBfsBlocks.length - finallyTailBlocks.length, finallyTailBlocks.length); - copyFinallyTailBlocks.forEach((copyFinallyTailBlock: BasicBlock) => { - const successorsCnt = copyFinallyTailBlock.getSuccessors().length; - copyFinallyTailBlock.getSuccessors().splice(0, successorsCnt); - }); if (copyFinallyTailBlocks.length > 1) { const newCopyFinallyTailBlock = new BasicBlock(); copyFinallyTailBlocks.forEach((copyFinallyTailBlock: BasicBlock) => { copyFinallyTailBlock.addSuccessorBlock(newCopyFinallyTailBlock); newCopyFinallyTailBlock.addPredecessorBlock(copyFinallyTailBlock); }); + copyFinallyBfsBlocks.push(...copyFinallyTailBlocks); copyFinallyTailBlocks = [newCopyFinallyTailBlock]; } - copyFinallyTailBlocks[0]?.addStmt(throwStmt); + copyFinallyTailBlocks[0].addStmt(throwStmt); copyFinallyBfsBlocks.push(...copyFinallyTailBlocks); copyFinallyBfsBlocks.forEach((copyFinallyBfsBlock: BasicBlock) => { basicBlockSet.add(copyFinallyBfsBlock); @@ -281,12 +287,19 @@ export class TrapBuilder { for (const sourceBlock of sourceBlocks) { const targetBlock = sourceToTarget.get(sourceBlock)!; for (const predecessor of sourceBlock.getPredecessors()) { - const targetPredecessor = sourceToTarget.get(predecessor)!; - targetBlock.addPredecessorBlock(targetPredecessor); + const targetPredecessor = sourceToTarget.get(predecessor); + // Only include blocks within the copy range, so that predecessor and successor relationships to + // external blocks can be trimmed + if (targetPredecessor) { + targetBlock.addPredecessorBlock(targetPredecessor); + } + } for (const successor of sourceBlock.getSuccessors()) { - const targetSuccessor = sourceToTarget.get(successor)!; - targetBlock.addSuccessorBlock(targetSuccessor); + const targetSuccessor = sourceToTarget.get(successor); + if (targetSuccessor) { + targetBlock.addSuccessorBlock(targetSuccessor); + } } } return targetBlocks; diff --git a/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts b/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts index f3476d3567b9c43686118ab0ebe8d4f1d266d61e..789e940e89e7af354526b94655f8b339f45436b5 100644 --- a/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts +++ b/ets2panda/linter/arkanalyzer/src/core/model/ArkMethod.ts @@ -15,7 +15,16 @@ import { ArkParameterRef, ArkThisRef } from '../base/Ref'; import { ArkAssignStmt, ArkReturnStmt, Stmt } from '../base/Stmt'; -import { ClassType, EnumValueType, FunctionType, GenericType, LiteralType, Type, UnionType } from '../base/Type'; +import { + AliasType, + ClassType, + EnumValueType, + FunctionType, + GenericType, + LiteralType, + Type, + UnionType +} from '../base/Type'; import { Value } from '../base/Value'; import { Cfg } from '../graph/Cfg'; import { ViewTree } from '../graph/ViewTree'; @@ -24,17 +33,17 @@ import { ArkClass, ClassCategory } from './ArkClass'; import { MethodSignature, MethodSubSignature } from './ArkSignature'; import { BodyBuilder } from './builder/BodyBuilder'; import { ArkExport, ExportType } from './ArkExport'; -import { ANONYMOUS_METHOD_PREFIX, DEFAULT_ARK_METHOD_NAME } from '../common/Const'; +import { ANONYMOUS_METHOD_PREFIX, DEFAULT_ARK_METHOD_NAME, LEXICAL_ENV_NAME_PREFIX } from '../common/Const'; import { getColNo, getLineNo, LineCol, setCol, setLine } from '../base/Position'; import { ArkBaseModel, ModifierType } from './ArkBaseModel'; import { ArkError, ArkErrorCode } from '../common/ArkError'; import { CALL_BACK } from '../common/EtsConst'; -import { Scene } from '../../Scene'; import { Constant } from '../base/Constant'; import { Local } from '../base/Local'; import { ArkFile, Language } from './ArkFile'; import { CONSTRUCTOR_NAME } from '../common/TSConst'; import { MethodParameter } from './builder/ArkMethodBuilder'; +import { TypeInference } from '../common/TypeInference'; export const arkMethodNodeKind = [ 'MethodDeclaration', @@ -623,45 +632,46 @@ export class ArkMethod extends ArkBaseModel implements ArkExport { } return args.length >= min && args.length <= max; }); - const scene = this.getDeclaringArkFile().getScene(); return ( - signatures?.find(p => { - const parameters = p.getMethodSubSignature().getParameters(); - for (let i = 0; i < parameters.length; i++) { - if (!args[i]) { - return parameters[i].isOptional(); - } - const isMatched = this.matchParam(parameters[i].getType(), args[i], scene); - if (!isMatched) { - return false; - } - } - return true; - }) ?? + signatures?.find(p => this.isMatched(p.getMethodSubSignature().getParameters(), args)) ?? signatures?.[0] ?? this.getSignature() ); } - private matchParam(paramType: Type, arg: Value, scene: Scene): boolean { - const argType = arg.getType(); - if (arg instanceof Local) { - const stmt = arg.getDeclaringStmt(); - if (stmt instanceof ArkAssignStmt && stmt.getRightOp() instanceof Constant) { - arg = stmt.getRightOp(); + private isMatched(parameters: MethodParameter[], args: Value[], isArrowFunc: boolean = false): boolean { + for (let i = 0; i < parameters.length; i++) { + if (!args[i]) { + return isArrowFunc ? true : parameters[i].isOptional(); } + const paramType = parameters[i].getType(); + const isMatched = this.matchParam(paramType, args[i]); + if (!isMatched) { + return false; + } else if (paramType instanceof EnumValueType || paramType instanceof LiteralType) { + return true; + } + } + return true; + } + + private matchParam(paramType: Type, arg: Value): boolean { + if (paramType instanceof EnumValueType || paramType instanceof LiteralType) { + arg = ArkMethod.parseArg(arg); + } + const argType = arg.getType(); + if (paramType instanceof AliasType && !(argType instanceof AliasType)) { + paramType = TypeInference.replaceAliasType(paramType); } if (paramType instanceof UnionType) { - let matched = false; - for (const e of paramType.getTypes()) { - if (argType.constructor === e.constructor) { - matched = true; - break; - } - } - return matched; + return !!paramType.getTypes().find(p => this.matchParam(p, arg)); } else if (argType instanceof FunctionType && paramType instanceof FunctionType) { - return argType.getMethodSignature().getParamLength() === paramType.getMethodSignature().getParamLength(); + if (argType.getMethodSignature().getParamLength() > paramType.getMethodSignature().getParamLength()) { + return false; + } + const parameters = paramType.getMethodSignature().getMethodSubSignature().getParameters(); + const args = argType.getMethodSignature().getMethodSubSignature().getParameters().filter(p => !p.getName().startsWith(LEXICAL_ENV_NAME_PREFIX)); + return this.isMatched(parameters, args, true); } else if (paramType instanceof ClassType && paramType.getClassSignature().getClassName().includes(CALL_BACK)) { return argType instanceof FunctionType; } else if (paramType instanceof LiteralType && arg instanceof Constant) { @@ -684,6 +694,19 @@ export class ArkMethod extends ArkBaseModel implements ArkExport { return argType.constructor === paramType.constructor; } + private static parseArg(arg: Value): Value { + if (arg instanceof Local) { + const stmt = arg.getDeclaringStmt(); + const argType = arg.getType(); + if (argType instanceof EnumValueType && argType.getConstant()) { + arg = argType.getConstant()!; + } else if (stmt instanceof ArkAssignStmt && stmt.getRightOp() instanceof Constant) { + arg = stmt.getRightOp(); + } + } + return arg; + } + public getOuterMethod(): ArkMethod | undefined { return this.outerMethod; } diff --git a/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkClassBuilder.ts b/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkClassBuilder.ts index 7c3f16938470b32b10ed1636e6a0354baa1baa73..dcef17ac8d8d1652c207ddf6fd80ee92e9d085b4 100644 --- a/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkClassBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/core/model/builder/ArkClassBuilder.ts @@ -370,7 +370,17 @@ function buildArkClassMembers(clsNode: ClassLikeNode, cls: ArkClass, sourceFile: const instanceInitStmts: Stmt[] = []; let staticBlockId = 0; clsNode.members.forEach(member => { - if (ts.isPropertyDeclaration(member) || ts.isPropertySignature(member)) { + if ( + ts.isMethodDeclaration(member) || + ts.isConstructorDeclaration(member) || + ts.isMethodSignature(member) || + ts.isConstructSignatureDeclaration(member) || + ts.isAccessor(member) || + ts.isCallSignatureDeclaration(member) + ) { + // these node types have been handled at the beginning of this function by calling buildMethodsForClass + return; + } else if (ts.isPropertyDeclaration(member) || ts.isPropertySignature(member)) { const arkField = buildProperty2ArkField(member, sourceFile, cls); if (ts.isClassDeclaration(clsNode) || ts.isClassExpression(clsNode) || ts.isStructDeclaration(clsNode)) { if (arkField.isStatic()) { @@ -395,9 +405,9 @@ function buildArkClassMembers(clsNode: ClassLikeNode, cls: ArkClass, sourceFile: const staticBlockInvokeExpr = new ArkStaticInvokeExpr(currStaticBlockMethodSig, []); staticInitStmts.push(new ArkInvokeStmt(staticBlockInvokeExpr)); } else if (ts.isSemicolonClassElement(member)) { - logger.debug('Skip these members.'); + logger.trace('Skip these members.'); } else { - logger.warn('Please contact developers to support new member type!'); + logger.warn(`Please contact developers to support new member in class: ${cls.getSignature().toString()}, member: ${member.getText()}!`); } }); if (ts.isClassDeclaration(clsNode) || ts.isClassExpression(clsNode) || ts.isStructDeclaration(clsNode)) { @@ -456,6 +466,9 @@ function buildParameterProperty2ArkField(params: ts.NodeArray namespace.addExportInfo(item)); } else { - logger.info('Child joined default method of arkFile: ', ts.SyntaxKind[child.kind]); + logger.trace('Child joined default method of arkFile: ', ts.SyntaxKind[child.kind]); // join default method } }); diff --git a/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts b/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts index 77b28a411fc80b6884620cdf50e2d5e564b93a81..8a6286bd30e384e17be1bae4bfbfd520df6bcbd1 100644 --- a/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts +++ b/ets2panda/linter/arkanalyzer/src/core/model/builder/BodyBuilder.ts @@ -571,6 +571,7 @@ export class BodyBuilder { const closuresLocal = new Local(closuresParam.getName(), lexicalEnv); body.addLocal(closuresLocal.getName(), closuresLocal); let assignStmt = new ArkAssignStmt(closuresLocal, parameterRef); + assignStmt.setCfg(body.getCfg()); stmts.splice(index, 0, assignStmt); closuresLocal.setDeclaringStmt(assignStmt); @@ -590,6 +591,7 @@ export class BodyBuilder { index++; const closureFieldRef = new ClosureFieldRef(closuresParam, closure.getName(), closure.getType()); let assignStmt = new ArkAssignStmt(local, closureFieldRef); + assignStmt.setCfg(body.getCfg()); stmts.splice(index, 0, assignStmt); local.setDeclaringStmt(assignStmt); closuresLocal.addUsedStmt(assignStmt); diff --git a/ets2panda/linter/arkanalyzer/src/save/JsonPrinter.ts b/ets2panda/linter/arkanalyzer/src/save/JsonPrinter.ts index 283de26011aae158e95d678fccdac4a6ceed70b4..e9c2696bf8a6b6df1c57670ffd481b09075eb1e1 100644 --- a/ets2panda/linter/arkanalyzer/src/save/JsonPrinter.ts +++ b/ets2panda/linter/arkanalyzer/src/save/JsonPrinter.ts @@ -22,20 +22,20 @@ import { ArkField } from '../core/model/ArkField'; import { AliasType, AnnotationNamespaceType, - AnnotationType, AnnotationTypeQueryType, AnyType, ArrayType, BigIntType, BooleanType, ClassType, + EnumValueType, FunctionType, GenericType, + IntersectionType, LiteralType, NeverType, NullType, NumberType, - PrimitiveType, StringType, TupleType, Type, @@ -46,11 +46,16 @@ import { VoidType, } from '../core/base/Type'; import { Value } from '../core/base/Value'; -import { ArkAssignStmt, ArkIfStmt, ArkInvokeStmt, ArkReturnStmt, ArkReturnVoidStmt, ArkThrowStmt, Stmt } from '../core/base/Stmt'; import { - AbstractBinopExpr, - AbstractExpr, - AbstractInvokeExpr, + ArkAssignStmt, + ArkIfStmt, + ArkInvokeStmt, + ArkReturnStmt, + ArkReturnVoidStmt, + ArkThrowStmt, + Stmt, +} from '../core/base/Stmt'; +import { ArkAwaitExpr, ArkCastExpr, ArkConditionExpr, @@ -73,13 +78,12 @@ import { ImportInfo } from '../core/model/ArkImport'; import { ExportInfo } from '../core/model/ArkExport'; import { AliasTypeSignature, ClassSignature, FieldSignature, FileSignature, MethodSignature, NamespaceSignature } from '../core/model/ArkSignature'; import { LineColPosition } from '../core/base/Position'; -import { AbstractFieldRef, AbstractRef, ArkArrayRef, ArkInstanceFieldRef, ArkParameterRef, ArkStaticFieldRef, ArkThisRef } from '../core/base/Ref'; +import { ArkArrayRef, ArkCaughtExceptionRef, ArkInstanceFieldRef, ArkParameterRef, ArkStaticFieldRef, ArkThisRef, ClosureFieldRef, GlobalRef } from '../core/base/Ref'; import { Local } from '../core/base/Local'; import { Cfg } from '../core/graph/Cfg'; import { BasicBlock } from '../core/graph/BasicBlock'; import { ArkBody } from '../core/model/ArkBody'; import { Decorator } from '../core/base/Decorator'; -import util from 'util'; export class JsonPrinter extends Printer { constructor(private arkFile: ArkFile) { @@ -113,8 +117,9 @@ export class JsonPrinter extends Printer { return { signature: this.serializeClassSignature(clazz.getSignature()), modifiers: clazz.getModifiers(), - decorators: clazz.getDecorators().map(decorator => this.serializeDecorator(decorator)), - typeParameters: clazz.getGenericsTypes()?.map(type => this.serializeType(type)), + decorators: clazz.getDecorators().map((decorator) => this.serializeDecorator(decorator)), + typeParameters: clazz.getGenericsTypes()?.map((type) => this.serializeType(type)), + category: clazz.getCategory(), superClassName: clazz.getSuperClassName(), implementedInterfaceNames: clazz.getImplementedInterfaceNames(), fields: clazz.getFields().map(field => this.serializeField(field)), @@ -155,6 +160,7 @@ export class JsonPrinter extends Printer { name: parameter.getName(), type: this.serializeType(parameter.getType()), isOptional: parameter.isOptional(), + isRest: parameter.hasDotDotDotToken(), }; } @@ -220,6 +226,11 @@ export class JsonPrinter extends Printer { _: 'UnionType', types: type.getTypes().map(type => this.serializeType(type)), }; + } else if (type instanceof IntersectionType) { + return { + _: 'IntersectionType', + types: type.getTypes().map((type) => this.serializeType(type)), + }; } else if (type instanceof TupleType) { return { _: 'TupleType', @@ -254,8 +265,6 @@ export class JsonPrinter extends Printer { _: 'LiteralType', literal: type.getLiteralName(), }; - } else if (type instanceof PrimitiveType) { - throw new Error('Unhandled PrimitiveType: ' + util.inspect(type, { showHidden: true, depth: null })); } else if (type instanceof ClassType) { return { _: 'ClassType', @@ -281,13 +290,13 @@ export class JsonPrinter extends Printer { typeParameters: type.getGenericTypes().map(type => this.serializeType(type)), }; } else if (type instanceof GenericType) { - let defaultType = type.getDefaultType(); let constraint = type.getConstraint(); + let defaultType = type.getDefaultType(); return { _: 'GenericType', name: type.getName(), - defaultType: defaultType && this.serializeType(defaultType), constraint: constraint && this.serializeType(constraint), + defaultType: defaultType && this.serializeType(defaultType), }; } else if (type instanceof AliasType) { return { @@ -307,10 +316,19 @@ export class JsonPrinter extends Printer { _: 'AnnotationTypeQueryType', originType: type.getOriginType(), }; - } else if (type instanceof AnnotationType) { - throw new Error('Unhandled AnnotationType: ' + util.inspect(type, { showHidden: true, depth: null })); + } else if (type instanceof EnumValueType) { + const c = type.getConstant(); + return { + _: 'EnumValueType', + signature: this.serializeFieldSignature(type.getFieldSignature()), + constant: c && this.serializeValue(c), + }; } else { - throw new Error('Unhandled Type: ' + util.inspect(type, { showHidden: true, depth: null })); + console.warn(`Unhandled Type: ${type.constructor.name} (${type.toString()})`); + return { + _: type.constructor.name, + text: type.toString(), + }; } } @@ -415,6 +433,13 @@ export class JsonPrinter extends Printer { }; } + private serializeConstant(constant: Constant): object { + return { + value: constant.getValue(), + type: this.serializeType(constant.getType()), + }; + } + private serializeValue(value: Value): object { if (value === undefined) { throw new Error('Value is undefined'); @@ -428,8 +453,7 @@ export class JsonPrinter extends Printer { } else if (value instanceof Constant) { return { _: 'Constant', - value: value.getValue(), - type: this.serializeType(value.getType()), + ...this.serializeConstant(value), }; } else if (value instanceof ArkNewExpr) { return { @@ -498,8 +522,6 @@ export class JsonPrinter extends Printer { left: this.serializeValue(value.getOp1()), right: this.serializeValue(value.getOp2()), }; - } else if (value instanceof AbstractBinopExpr) { - return new Error('Unhandled BinopExpr: ' + util.inspect(value, { showHidden: true, depth: null })); } else if (value instanceof ArkUnopExpr) { return { _: 'UnopExpr', @@ -526,8 +548,6 @@ export class JsonPrinter extends Printer { method: this.serializeMethodSignature(value.getMethodSignature()), args: value.getArgs().map(arg => this.serializeValue(arg)), }; - } else if (value instanceof AbstractInvokeExpr) { - throw new Error('Unhandled CallExpr: ' + util.inspect(value, { showHidden: true, depth: null })); } else if (value instanceof ArkThisRef) { return { _: 'ThisRef', @@ -546,6 +566,25 @@ export class JsonPrinter extends Printer { index: this.serializeValue(value.getIndex()), type: this.serializeType(value.getType()), }; + } else if (value instanceof ArkCaughtExceptionRef) { + return { + _: 'CaughtExceptionRef', + type: this.serializeType(value.getType()), + }; + } else if (value instanceof GlobalRef) { + let ref = value.getRef(); + return { + _: 'GlobalRef', + name: value.getName(), + ref: ref ? this.serializeValue(ref) : null, + }; + } else if (value instanceof ClosureFieldRef) { + return { + _: 'ClosureFieldRef', + base: this.serializeLocal(value.getBase()), + fieldName: value.getFieldName(), + type: this.serializeType(value.getType()), + }; } else if (value instanceof ArkInstanceFieldRef) { return { _: 'InstanceFieldRef', @@ -557,14 +596,13 @@ export class JsonPrinter extends Printer { _: 'StaticFieldRef', field: this.serializeFieldSignature(value.getFieldSignature()), }; - } else if (value instanceof AbstractFieldRef) { - throw new Error('Unhandled FieldRef: ' + util.inspect(value, { showHidden: true, depth: null })); - } else if (value instanceof AbstractRef) { - throw new Error('Unhandled Ref: ' + util.inspect(value, { showHidden: true, depth: null })); - } else if (value instanceof AbstractExpr) { - throw new Error('Unhandled Expr: ' + util.inspect(value, { showHidden: true, depth: null })); } else { - throw new Error('Unhandled Value: ' + util.inspect(value, { showHidden: true, depth: null })); + console.warn(`Unhandled Value: ${value.constructor.name} (${value.toString()})`); + return { + _: value.constructor.name, + text: value.toString(), + type: this.serializeType(value.getType()), + }; } } @@ -600,7 +638,11 @@ export class JsonPrinter extends Printer { arg: this.serializeValue(stmt.getOp()), }; } else { - throw new Error('Unhandled Stmt: ' + util.inspect(stmt, { showHidden: true, depth: null })); + console.warn(`Unhandled Stmt: ${stmt.constructor.name} (${stmt.toString()})`); + return { + _: stmt.constructor.name, + text: stmt.toString(), + }; } } } diff --git a/ets2panda/linter/arkanalyzer/src/save/source/SourceBody.ts b/ets2panda/linter/arkanalyzer/src/save/source/SourceBody.ts index b33546dce3edac6d742866e3c89ffdc14520ebb6..d1437e94dcab65f8a38b263f3d02ea389dc544a1 100644 --- a/ets2panda/linter/arkanalyzer/src/save/source/SourceBody.ts +++ b/ets2panda/linter/arkanalyzer/src/save/source/SourceBody.ts @@ -126,8 +126,9 @@ export class SourceBody implements StmtPrinterContext { this.tempCodeMap.set(temp, code); } - public transTemp2Code(temp: Local): string { - if (this.tempCodeMap.has(temp.getName()) && PrinterUtils.isTemp(temp.getName())) { + public transTemp2Code(temp: Local, isLeftOp: boolean = false): string { + // if the temp local is not the left op of ArkAssignStmt, it should get the actual text from tempCodeMap + if (!isLeftOp && this.tempCodeMap.has(temp.getName()) && PrinterUtils.isTemp(temp.getName())) { this.tempVisitor.add(temp.getName()); return this.tempCodeMap.get(temp.getName())!; } diff --git a/ets2panda/linter/arkanalyzer/src/save/source/SourceStmt.ts b/ets2panda/linter/arkanalyzer/src/save/source/SourceStmt.ts index 6f73ec3dc85405df20be70e1a3dd71bed1852d16..78452b5658602cb85b5f3182e5e23bc9ea66b846 100644 --- a/ets2panda/linter/arkanalyzer/src/save/source/SourceStmt.ts +++ b/ets2panda/linter/arkanalyzer/src/save/source/SourceStmt.ts @@ -14,10 +14,31 @@ */ import { Constant } from '../../core/base/Constant'; -import { ArkInstanceInvokeExpr, ArkNewArrayExpr, ArkNewExpr, ArkStaticInvokeExpr, NormalBinaryOperator } from '../../core/base/Expr'; +import { + ArkInstanceInvokeExpr, + ArkNewArrayExpr, + ArkNewExpr, + ArkStaticInvokeExpr, + NormalBinaryOperator +} from '../../core/base/Expr'; import { Local } from '../../core/base/Local'; -import { ArkArrayRef, ArkInstanceFieldRef, ArkParameterRef, ArkStaticFieldRef, ClosureFieldRef } from '../../core/base/Ref'; -import { ArkAliasTypeDefineStmt, ArkAssignStmt, ArkIfStmt, ArkInvokeStmt, ArkReturnStmt, ArkReturnVoidStmt, ArkThrowStmt, Stmt } from '../../core/base/Stmt'; +import { + ArkArrayRef, + ArkInstanceFieldRef, + ArkParameterRef, + ArkStaticFieldRef, + ClosureFieldRef +} from '../../core/base/Ref'; +import { + ArkAliasTypeDefineStmt, + ArkAssignStmt, + ArkIfStmt, + ArkInvokeStmt, + ArkReturnStmt, + ArkReturnVoidStmt, + ArkThrowStmt, + Stmt +} from '../../core/base/Stmt'; import { AliasType, ClassType, Type } from '../../core/base/Type'; import { Value } from '../../core/base/Value'; import { BasicBlock } from '../../core/graph/BasicBlock'; @@ -166,7 +187,7 @@ export class SourceAssignStmt extends SourceStmt { return; } - this.leftCode = this.transformer.valueToString(this.leftOp); + this.leftCode = this.transformer.valueToString(this.leftOp, true); if (this.leftOp instanceof Local && this.rightOp instanceof ArkNewExpr) { this.transferRightNewExpr(); @@ -380,8 +401,8 @@ export class SourceInvokeStmt extends SourceStmt { isAttr = PrinterUtils.isComponentIfElseInvoke(invokeExpr); } } else if (invokeExpr instanceof ArkInstanceInvokeExpr) { - code = this.transformer.instanceInvokeExprToString(invokeExpr); isAttr = PrinterUtils.isComponentAttributeInvoke(invokeExpr); + code = this.transformer.instanceInvokeExprToString(invokeExpr, isAttr); } if (code.length > 0 && !isAttr) { @@ -511,7 +532,7 @@ export class SourceWhileStmt extends SourceStmt { return false; } - if (iterator.getMethodSignature().getMethodSubSignature().getMethodName() !== 'iterator') { + if (iterator.getMethodSignature().getMethodSubSignature().getMethodName() !== 'Symbol.iterator') { return false; } diff --git a/ets2panda/linter/arkanalyzer/src/save/source/SourceTransformer.ts b/ets2panda/linter/arkanalyzer/src/save/source/SourceTransformer.ts index 58c999d85b7244db2cb2093eca392863103849af..d199e7fc17c1c046d120b1e74d89142548d611af 100644 --- a/ets2panda/linter/arkanalyzer/src/save/source/SourceTransformer.ts +++ b/ets2panda/linter/arkanalyzer/src/save/source/SourceTransformer.ts @@ -60,7 +60,12 @@ import { SourceClass } from './SourceClass'; import { Value } from '../../core/base/Value'; import { AbstractRef, ArkArrayRef, ArkInstanceFieldRef, ArkStaticFieldRef, ArkThisRef } from '../../core/base/Ref'; import { ArkFile } from '../../core/model/ArkFile'; -import { COMPONENT_CREATE_FUNCTION, COMPONENT_CUSTOMVIEW, COMPONENT_IF, COMPONENT_POP_FUNCTION } from '../../core/common/EtsConst'; +import { + COMPONENT_CREATE_FUNCTION, + COMPONENT_CUSTOMVIEW, + COMPONENT_IF, + COMPONENT_POP_FUNCTION +} from '../../core/common/EtsConst'; import { INSTANCE_INIT_METHOD_NAME } from '../../core/common/Const'; import { ArkAssignStmt } from '../../core/base/Stmt'; import { ArkNamespace } from '../../core/model/ArkNamespace'; @@ -84,7 +89,7 @@ export interface TransformerContext { getPrinter(): ArkCodeBuffer; - transTemp2Code(temp: Local): string; + transTemp2Code(temp: Local, isLeftOp: boolean): string; isInBuilderMethod(): boolean; } @@ -107,7 +112,7 @@ export class SourceTransformer { return clsPrinter.dump().trimStart(); } - public instanceInvokeExprToString(invokeExpr: ArkInstanceInvokeExpr): string { + public instanceInvokeExprToString(invokeExpr: ArkInstanceInvokeExpr, isAttr: boolean): string { let methodName = invokeExpr.getMethodSignature().getMethodSubSignature().getMethodName(); if (methodName === INSTANCE_INIT_METHOD_NAME) { return ''; @@ -116,9 +121,8 @@ export class SourceTransformer { invokeExpr.getArgs().forEach(v => { args.push(this.valueToString(v)); }); - let genericCode = this.genericTypesToString(invokeExpr.getRealGenericTypes()); - - if (PrinterUtils.isComponentAttributeInvoke(invokeExpr) && this.context.isInBuilderMethod()) { + let genericCode = isAttr ? '' : this.genericTypesToString(invokeExpr.getRealGenericTypes()); + if (isAttr && this.context.isInBuilderMethod()) { return `.${methodName}${genericCode}(${args.join(', ')})`; } @@ -227,7 +231,8 @@ export class SourceTransformer { private exprToString(expr: AbstractExpr): string { if (expr instanceof ArkInstanceInvokeExpr) { - return `${this.instanceInvokeExprToString(expr)}`; + const isAttr = PrinterUtils.isComponentAttributeInvoke(expr); + return `${this.instanceInvokeExprToString(expr, isAttr)}`; } if (expr instanceof ArkStaticInvokeExpr) { @@ -251,7 +256,7 @@ export class SourceTransformer { let op2: Value = expr.getOp2(); let operator: string = expr.getOperator(); - return `${this.valueToString(op1, operator)} ${operator} ${this.valueToString(op2, operator)}`; + return `${this.valueToString(op1, false, operator)} ${operator} ${this.valueToString(op2, false, operator)}`; } if (expr instanceof ArkTypeOfExpr) { @@ -310,7 +315,7 @@ export class SourceTransformer { return `${value}`; } - public valueToString(value: Value, operator?: string): string { + public valueToString(value: Value, isLeftOp: boolean = false, operator?: string): string { if (value instanceof AbstractExpr) { return this.exprToString(value); } @@ -324,14 +329,14 @@ export class SourceTransformer { } if (value instanceof Local) { - return this.localToString(value, operator); + return this.localToString(value, isLeftOp, operator); } logger.info(`valueToString ${value.constructor} not support.`); return `${value}`; } - private localToString(value: Local, operator?: string): string { + private localToString(value: Local, isLeftOp: boolean = false, operator?: string): string { if (PrinterUtils.isAnonymousMethod(value.getName())) { let methodSignature = (value.getType() as FunctionType).getMethodSignature(); let anonymousMethod = this.context.getMethod(methodSignature); @@ -351,12 +356,12 @@ export class SourceTransformer { if (PrinterUtils.isTemp(value.getName())) { let stmt = value.getDeclaringStmt(); if (stmt instanceof ArkAssignStmt && stmt.getRightOp() instanceof ArkNormalBinopExpr) { - return `(${this.context.transTemp2Code(value)})`; + return `(${this.context.transTemp2Code(value, isLeftOp)})`; } } } - return this.context.transTemp2Code(value); + return this.context.transTemp2Code(value, isLeftOp); } public literalObjectToString(type: ClassType): string { diff --git a/ets2panda/linter/arkanalyzer/src/transformer/StaticSingleAssignmentFormer.ts b/ets2panda/linter/arkanalyzer/src/transformer/StaticSingleAssignmentFormer.ts index 2c7e78deec68bd3715c15e00bee27a851f6580d1..1f1383c18ccfdbed2d7211a3df07ad6a26297e28 100644 --- a/ets2panda/linter/arkanalyzer/src/transformer/StaticSingleAssignmentFormer.ts +++ b/ets2panda/linter/arkanalyzer/src/transformer/StaticSingleAssignmentFormer.ts @@ -73,7 +73,7 @@ export class StaticSingleAssignmentFormer { let phiBlocks = localToPhiBlock.get(local) as Set; let blocks = Array.from(localToBlocks.get(local) as Set); while (blocks.length !== 0) { - let block = blocks.splice(0, 1).at(0) as BasicBlock; + let block = blocks.splice(0, 1)[0] as BasicBlock; let dfs = dominanceFinder.getDominanceFrontiers(block); for (const df of dfs) { this.handleDf(blockToPhiStmts, blockToPhiLocals, phiBlocks, df, local, blockToDefs, blocks); diff --git a/ets2panda/linter/arkanalyzer/src/utils/SparseBitVector.ts b/ets2panda/linter/arkanalyzer/src/utils/SparseBitVector.ts index fcb5c816ac5f5b5ef8e9b4f3ace185db43c041c4..313fb88f359040faa8c3ffbe7c681a5120e1a9ae 100644 --- a/ets2panda/linter/arkanalyzer/src/utils/SparseBitVector.ts +++ b/ets2panda/linter/arkanalyzer/src/utils/SparseBitVector.ts @@ -538,7 +538,6 @@ export class SparseBitVector { return changed; } - // Dump as string toString(): string { let ar = [...this]; return ar.toString(); diff --git a/ets2panda/linter/arkanalyzer/typedoc.json b/ets2panda/linter/arkanalyzer/typedoc.json index 1b08d68d6925c2b388da76585a545eef75630cf4..e582cf129b3186e882113f1961d5b90c729e0745 100644 --- a/ets2panda/linter/arkanalyzer/typedoc.json +++ b/ets2panda/linter/arkanalyzer/typedoc.json @@ -16,6 +16,7 @@ ], "excludeInternal": true, "useTsLinkResolution": true, + "plugin": "typedoc-plugin-markdown", "out": "docs/api_docs", "readme": "./README.en.md" } \ No newline at end of file diff --git a/ets2panda/linter/build_linter.py b/ets2panda/linter/build_linter.py index cfc970134ce210b74707b51b6b07175bf34cb7c9..3634b84a25fa84e56a86343f8b0b5316acaf8a3f 100755 --- a/ets2panda/linter/build_linter.py +++ b/ets2panda/linter/build_linter.py @@ -36,6 +36,9 @@ def copy_files(source_path, dest_path, is_file=False): def run_cmd(cmd, execution_path=None): + if (cmd and cmd[0].strip().endswith('npm')): + cmd.append('--registry') + cmd.append('https://repo.huaweicloud.com/repository/npm/') proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, @@ -48,15 +51,24 @@ def run_cmd(cmd, execution_path=None): def run_cmd_with_retry(max_retries, wait_time, cmd, execution_path=None): retry_count = 0 + last_exception = None while retry_count < max_retries: try: run_cmd(cmd, execution_path) break - except Exception: + except Exception as e: + last_exception = e retry_count += 1 time.sleep(wait_time) if retry_count >= max_retries: - raise Exception("Failed to run cmd: " + cmd) + raise Exception( + "Command failed after {r} attempts. Cmd: {c}. Error: {e}" + .format( + r=max_retries, + c=" ".join(cmd), + e=last_exception + ) + ) def is_npm_newer_than_6(options): diff --git a/ets2panda/linter/homecheck/ruleSet.json b/ets2panda/linter/homecheck/ruleSet.json index adfc2898b56f1dc1b440bbe682d6abdf1d9c2fa0..1dcacfee1bcf344047eee95418f60fcb9edb9689 100644 --- a/ets2panda/linter/homecheck/ruleSet.json +++ b/ets2panda/linter/homecheck/ruleSet.json @@ -208,6 +208,8 @@ "@migration/interop-dynamic-object-literals": 1, "@migration/interop-assign": 1, "@migration/interop-boxed-type-check": 1, - "@migration/interop-js-modify-property": 1 + "@migration/interop-js-modify-property": 1, + "@migration/arkts-interop-s2d-object-literal": 1, + "@migration/arkts-interop-s2d-dynamic-call-builtin-api-not-in-static": 1 } -} +} \ No newline at end of file diff --git a/ets2panda/linter/homecheck/src/Index.ts b/ets2panda/linter/homecheck/src/Index.ts index 6ad78b6bfe25006f6ab5f366effe38a2e7136803..b3228e9bd598c32c541a12874d949bdf8559b560 100644 --- a/ets2panda/linter/homecheck/src/Index.ts +++ b/ets2panda/linter/homecheck/src/Index.ts @@ -42,4 +42,4 @@ export { Utils } from './utils/common/Utils'; // tools export { runTool, Tools } from './tools/toolEntry'; -export { MigrationTool } from './tools/migrationTool/MigrationTool'; +export { MigrationTool } from './tools/migrationTool/MigrationTool'; \ No newline at end of file diff --git a/ets2panda/linter/homecheck/src/checker/migration/AppStorageGetCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/AppStorageGetCheck.ts index 693f8914126a9a7d9a5da0d9e697963b77e5e460..8e1ef29f16e35b25605f8c61be37708dc72dd945 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/AppStorageGetCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/AppStorageGetCheck.ts @@ -139,7 +139,7 @@ export class AppStorageGetCheck implements BaseChecker { } private getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); diff --git a/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts index b8dcb06db7d2c47226110a65dfc9298937fdc42c..5243a14f39093494e6317dfd50a6f92dd0884c40 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/CustomBuilderCheck.ts @@ -149,15 +149,18 @@ export class CustomBuilderCheck implements BaseChecker { } private isPassToCustomBuilder(stmt: Stmt, locals: Set): Local | undefined { + let res: Local | undefined = undefined; if (stmt instanceof ArkAssignStmt) { - if (!this.isCustomBuilderTy(stmt.getLeftOp().getType())) { - return undefined; - } - const rightOp = stmt.getRightOp(); - if (rightOp instanceof Local && locals.has(rightOp)) { - return rightOp; + if (this.isCustomBuilderTy(stmt.getLeftOp().getType())) { + const rightOp = stmt.getRightOp(); + if (rightOp instanceof Local && locals.has(rightOp)) { + res = rightOp; + } } } + if (res !== undefined) { + return res; + } const invokeExpr = stmt.getInvokeExpr(); if (invokeExpr) { const paramTys = invokeExpr.getMethodSignature().getMethodSubSignature().getParameterTypes(); @@ -208,7 +211,7 @@ export class CustomBuilderCheck implements BaseChecker { } private getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); @@ -229,7 +232,7 @@ export class CustomBuilderCheck implements BaseChecker { fixPosition.endLine = endPosition.line; fixPosition.endCol = endPosition.col; } - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const sourceFile = AstTreeUtils.getASTNode(arkFile.getName(), arkFile.getCode()); const range = FixUtils.getRangeWithAst(sourceFile, fixPosition); ruleFix.range = range; diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts index d956fe529c7181a55527a35c870cabde40d9c4d8..a17b9064bad53d862df042578e47360a71a8513b 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts @@ -98,7 +98,7 @@ export class InteropAssignCheck implements BaseChecker { callsites.forEach(cs => { let hasTargetArg = false; const invoke = cs.getInvokeExpr()!; - const csMethod = cs.getCfg()?.getDeclaringMethod(); + const csMethod = cs.getCfg().getDeclaringMethod(); invoke.getArgs().forEach(arg => { const argTy = arg.getType(); if (argTy instanceof PrimitiveType || this.isBoxedType(argTy)) { @@ -149,7 +149,7 @@ export class InteropAssignCheck implements BaseChecker { const desc = `${this.metaData.description} (${RULE_ID})`; const severity = this.metaData.severity; const ruleId = this.rule.ruleId; - const filePath = assign.getCfg()?.getDeclaringMethod().getDeclaringArkFile()?.getFilePath() ?? ''; + const filePath = assign.getCfg().getDeclaringMethod().getDeclaringArkFile()?.getFilePath() ?? ''; const defeats = new Defects(line, column, column, problem, desc, severity, ruleId, filePath, '', true, false, false); this.issues.push(new IssueReport(defeats, undefined)); }); @@ -265,8 +265,6 @@ export class InteropAssignCheck implements BaseChecker { } if (file) { return file.getLanguage(); - } else { - logger.error(`fail to identify which file the type definition ${type.toString()} is in.`); } return undefined; } diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts index 9651894a32e058ab673a856c3b29f5581600baa6..7f231f51fa3db655bf3a89af303d2d8361a9625d 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropBackwardDFACheck.ts @@ -176,11 +176,14 @@ export class InteropBackwardDFACheck implements BaseChecker { const invoke = stmt.getInvokeExpr(); let isReflect = false; let paramIdx = -1; - if (invoke && invoke instanceof ArkInstanceInvokeExpr) { - if (invoke.getBase().getName() === 'Reflect') { + if (invoke && invoke instanceof ArkStaticInvokeExpr) { + const classSig = invoke.getMethodSignature().getDeclaringClassSignature(); + if ( + classSig.getDeclaringFileSignature().getProjectName() === 'built-in' && + classSig.getDeclaringNamespaceSignature()?.getNamespaceName() === 'Reflect' + ) { isReflect = true; - paramIdx = - REFLECT_API.get(invoke.getMethodSignature().getMethodSubSignature().getMethodName()) ?? -1; + paramIdx = REFLECT_API.get(invoke.getMethodSignature().getMethodSubSignature().getMethodName()) ?? -1; } } if (invoke && invoke instanceof ArkStaticInvokeExpr) { @@ -214,7 +217,7 @@ export class InteropBackwardDFACheck implements BaseChecker { private reportIssue(objDefInfo: ObjDefInfo, apiLang: Language, isReflect: boolean) { const problemStmt = objDefInfo.problemStmt; - const problemStmtMtd = problemStmt.getCfg()?.getDeclaringMethod(); + const problemStmtMtd = problemStmt.getCfg().getDeclaringMethod(); const problemStmtLang = problemStmtMtd?.getLanguage(); const objLanguage = objDefInfo.objLanguage; if (objLanguage === Language.UNKNOWN || problemStmtLang === Language.UNKNOWN) { diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropBoxedTypeCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropBoxedTypeCheck.ts index 42b4dc0973a789fe6d96f7a86e20bb8323dbbdf0..d0a1c9b10fa1064e34fd46de5cbbdbb79c1e2859 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropBoxedTypeCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropBoxedTypeCheck.ts @@ -40,7 +40,7 @@ import { WarnInfo } from '../../utils/common/Utils'; import { Language } from 'arkanalyzer/lib/core/model/ArkFile'; import { getLanguageStr } from './Utils'; -const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'ObservedDecoratorCheck'); +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'InteropBoxedTypeCheck'); const gMetaData: BaseMetaData = { severity: 1, ruleDocPath: '', diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropDeprecatedBuiltInAPICheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropDeprecatedBuiltInAPICheck.ts new file mode 100644 index 0000000000000000000000000000000000000000..b8af6a32c8cdb3e9640b21ab4cb1247e47e7abf3 --- /dev/null +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropDeprecatedBuiltInAPICheck.ts @@ -0,0 +1,928 @@ +/* + * 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 { + ArkMethod, + ArkAssignStmt, + FieldSignature, + Stmt, + Scene, + Value, + DVFGBuilder, + CallGraph, + ArkParameterRef, + ArkInstanceFieldRef, + ArkNamespace, + Local, + ClassType, + ArkField, + ClassSignature, + Type, + BooleanType, + FunctionType, + AnyType, + MethodSignature, + UnknownType, + GenericType, + NumberType, + ArrayType, + MethodSubSignature, + ArkInvokeStmt, + AbstractInvokeExpr, + ArkInstanceInvokeExpr, + ArkPtrInvokeExpr, + ImportInfo, + UnionType, + FileSignature, + ArkStaticInvokeExpr, + UndefinedType, + VoidType, +} from 'arkanalyzer/lib'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; +import { BaseChecker, BaseMetaData } from '../BaseChecker'; +import { Rule, Defects, MatcherCallback } from '../../Index'; +import { IssueReport } from '../../model/Defects'; +import { DVFG, DVFGNode } from 'arkanalyzer/lib/VFG/DVFG'; +import { CALL_DEPTH_LIMIT, getGlobalsDefineInDefaultMethod, GlobalCallGraphHelper } from './Utils'; +import { WarnInfo } from '../../utils/common/Utils'; +import { ArkClass } from 'arkanalyzer/lib/core/model/ArkClass'; +import { Language } from 'arkanalyzer/lib/core/model/ArkFile'; +import { MethodParameter } from 'arkanalyzer/lib/core/model/builder/ArkMethodBuilder'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'DeprecatedBuiltInAPICheck'); +const gMetaData: BaseMetaData = { + severity: 1, + ruleDocPath: '', + description: '', +}; + +enum APIBaseCategory { + Array = 'Array', + Set = 'Set', + Map = 'Map', +} + +class DeprecatedAPIInfo { + constructor( + public base: APIBaseCategory, + public name: string, + public isStatic: boolean, + public returnType?: Type, // return Type为undefined时表示不关心API的返回值 + public params?: Type[], // return Type为undefined时表示不关心API的形参,应该是整个API都被废弃,而非某一重载形态 + public targetParamIndex?: number // 若isStatic为tue,说明是静态接口,需要提供查找接口的第几个param是否来源arkts1.2,编号从0开始,不提供则查找base的来源 + ) {} +} + +class APIBasicType { + static readonly genericTypeT = new GenericType('T'); + static readonly genericTypeU = new GenericType('U'); + static readonly genericTypeV = new GenericType('V'); + static readonly genericTypeK = new GenericType('K'); + static readonly genericTypeS = new GenericType('S'); + static readonly arrayT = new ArrayType(this.genericTypeT, 1); + static readonly arrayU = new ArrayType(this.genericTypeU, 1); + static readonly unknownType = UnknownType.getInstance(); + static readonly numberType = NumberType.getInstance(); + static readonly booleanType = BooleanType.getInstance(); + static readonly anyType = AnyType.getInstance(); + static readonly undefinedType = UndefinedType.getInstance(); + static readonly voidType = VoidType.getInstance(); +} + +class APIComplicatedType { + static readonly anonyMethodName = 'anonymous'; + static readonly predicateFunctionType = this.createPredicateFunctionType(); + static readonly predicateFunction1Type = this.createPredicateFunction1Type(); + static readonly concatItemType = this.createConcatItemType(); + static readonly mapfnFunctionType = this.createMapfnFunctionType(); + static readonly ArrayLikeType = new ClassType(new ClassSignature('ArrayLike', FileSignature.DEFAULT)); + static readonly IterableType = new ClassType(new ClassSignature('Iterable', FileSignature.DEFAULT)); + static readonly SetType = new ClassType(new ClassSignature('Set', FileSignature.DEFAULT)); + static readonly MapType = new ClassType(new ClassSignature('Map', FileSignature.DEFAULT)); + static readonly setCallbackFnFunctionType = this.createSetCallbackFnFunctionType(); + static readonly mapCallbackFnFunctionType = this.createMapCallbackFnFunctionType(); + + // 对于参数类型一致,但是参数名称不同、返回值类型不同的FunctionType,视为同一个,不重新创建。因为FunctionType类型匹配的时候仅匹配参数类型 + // 不同的API,仅形参为lambda函数且该lambda函数的返回值不同,例如unknown和value is S类型谓词形式,视为同一个API + private static createPredicateFunctionType(): FunctionType { + const predicateValueParam = new MethodParameter(); + predicateValueParam.setName('value'); + predicateValueParam.setType(APIBasicType.genericTypeT); + const predicateIndexParam = new MethodParameter(); + predicateIndexParam.setName('index'); + predicateIndexParam.setType(APIBasicType.numberType); + const predicateArrayParam = new MethodParameter(); + predicateArrayParam.setName('array'); + predicateArrayParam.setType(APIBasicType.arrayT); + const predicateMethodSubSignature = new MethodSubSignature( + this.anonyMethodName, + [predicateValueParam, predicateIndexParam, predicateArrayParam], + APIBasicType.unknownType + ); + return new FunctionType(new MethodSignature(ClassSignature.DEFAULT, predicateMethodSubSignature)); + } + + private static createPredicateFunction1Type(): FunctionType { + const predicateThisParam = new MethodParameter(); + predicateThisParam.setName('this'); + predicateThisParam.setType(APIBasicType.voidType); + const predicateValueParam = new MethodParameter(); + predicateValueParam.setName('value'); + predicateValueParam.setType(APIBasicType.genericTypeT); + const predicateIndexParam = new MethodParameter(); + predicateIndexParam.setName('index'); + predicateIndexParam.setType(APIBasicType.numberType); + const predicateObjParam = new MethodParameter(); + predicateObjParam.setName('obj'); + predicateObjParam.setType(APIBasicType.arrayT); + const predicateMethodSubSignature = new MethodSubSignature( + this.anonyMethodName, + [predicateThisParam, predicateValueParam, predicateIndexParam, predicateObjParam], + APIBasicType.booleanType + ); + return new FunctionType(new MethodSignature(ClassSignature.DEFAULT, predicateMethodSubSignature)); + } + + private static createConcatItemType(): UnionType { + return new UnionType([APIBasicType.genericTypeT, new ClassType(new ClassSignature('ConcatArray', FileSignature.DEFAULT))]); + } + + private static createMapfnFunctionType(): FunctionType { + const mapfnParamV = new MethodParameter(); + mapfnParamV.setName('v'); + mapfnParamV.setType(APIBasicType.genericTypeT); + const mapfnParamK = new MethodParameter(); + mapfnParamK.setName('k'); + mapfnParamK.setType(APIBasicType.numberType); + const mapfnMethodSubSignature = new MethodSubSignature(this.anonyMethodName, [mapfnParamV, mapfnParamK], APIBasicType.genericTypeU); + return new FunctionType(new MethodSignature(ClassSignature.DEFAULT, mapfnMethodSubSignature)); + } + + private static createSetCallbackFnFunctionType(): FunctionType { + const callbackFnValueParam = new MethodParameter(); + callbackFnValueParam.setName('value'); + callbackFnValueParam.setType(APIBasicType.genericTypeT); + const callbackFnValue2Param = new MethodParameter(); + callbackFnValue2Param.setName('value2'); + callbackFnValue2Param.setType(APIBasicType.genericTypeT); + const callbackFnSetParam = new MethodParameter(); + callbackFnSetParam.setName('set'); + callbackFnSetParam.setType(this.SetType); + const predicateMethodSubSignature = new MethodSubSignature( + this.anonyMethodName, + [callbackFnValueParam, callbackFnValue2Param, callbackFnSetParam], + APIBasicType.voidType + ); + return new FunctionType(new MethodSignature(ClassSignature.DEFAULT, predicateMethodSubSignature)); + } + + private static createMapCallbackFnFunctionType(): FunctionType { + const callbackFnValueParam = new MethodParameter(); + callbackFnValueParam.setName('value'); + callbackFnValueParam.setType(APIBasicType.genericTypeV); + const callbackFnKeyParam = new MethodParameter(); + callbackFnKeyParam.setName('key'); + callbackFnKeyParam.setType(APIBasicType.genericTypeK); + const callbackFnMapParam = new MethodParameter(); + callbackFnMapParam.setName('map'); + callbackFnMapParam.setType(this.MapType); + const predicateMethodSubSignature = new MethodSubSignature( + this.anonyMethodName, + [callbackFnValueParam, callbackFnKeyParam, callbackFnMapParam], + APIBasicType.voidType + ); + return new FunctionType(new MethodSignature(ClassSignature.DEFAULT, predicateMethodSubSignature)); + } +} + +class DeprecatedAPIList { + static readonly DeprecatedAPIs: DeprecatedAPIInfo[] = [ + this.createArrayEveryAPI1(), + this.createArrayFilterAPI1(), + this.createArrayFindAPI1(), + this.createArrayFindAPI2(), + this.createArrayFindIndexAPI(), + this.createArrayForEachAPI(), + this.createArrayMapAPI(), + this.createArraySomeAPI(), + this.createArrayConcatAPI(), + this.createArrayFlatAPI(), + this.createArrayFlatMapAPI(), + this.createArrayFromArrayLikeAPI(), + this.createArrayFromIterableAndArrayLikeAPI(), + this.createSetForEachAPI(), + this.createMapForEachAPI(), + this.createArraySymbolIteratorAPI(), + this.createSetSymbolIteratorAPI(), + this.createMapSymbolIteratorAPI() + ]; + + private static createArrayEveryAPI1(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'every', false, APIBasicType.booleanType, [ + APIComplicatedType.predicateFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArrayFilterAPI1(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'filter', false, APIBasicType.arrayT, [ + APIComplicatedType.predicateFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArrayFindAPI1(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'find', false, new UnionType([APIBasicType.genericTypeT, APIBasicType.undefinedType]), [ + APIComplicatedType.predicateFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArrayFindAPI2(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'find', false, new UnionType([APIBasicType.genericTypeS, APIBasicType.undefinedType]), [ + APIComplicatedType.predicateFunction1Type, + APIBasicType.anyType, + ]); + } + + private static createArrayFindIndexAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'findIndex', false, APIBasicType.numberType, [ + APIComplicatedType.predicateFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArrayForEachAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'forEach', false, APIBasicType.voidType, [ + APIComplicatedType.predicateFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArrayMapAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'map', false, APIBasicType.arrayU, [ + APIComplicatedType.predicateFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArraySomeAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'some', false, APIBasicType.booleanType, [ + APIComplicatedType.predicateFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArrayConcatAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'concat', false, APIBasicType.arrayT, [new ArrayType(APIComplicatedType.concatItemType, 1)]); + } + + private static createArrayFlatAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'flat', false); + } + + private static createArrayFlatMapAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'flatMap', false); + } + + private static createArrayFromArrayLikeAPI(): DeprecatedAPIInfo { + const fromParams = [APIComplicatedType.ArrayLikeType, APIComplicatedType.mapfnFunctionType, APIBasicType.anyType]; + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'from', true, APIBasicType.arrayU, fromParams, 0); + } + + private static createArrayFromIterableAndArrayLikeAPI(): DeprecatedAPIInfo { + const fromParams = [ + new UnionType([APIComplicatedType.ArrayLikeType, APIComplicatedType.IterableType]), + APIComplicatedType.mapfnFunctionType, + APIBasicType.anyType, + ]; + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'from', true, APIBasicType.arrayU, fromParams, 0); + } + + private static createSetForEachAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Set, 'forEach', false, APIBasicType.voidType, [ + APIComplicatedType.setCallbackFnFunctionType, + APIBasicType.anyType, + ]); + } + + private static createMapForEachAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Map, 'forEach', false, APIBasicType.voidType, [ + APIComplicatedType.mapCallbackFnFunctionType, + APIBasicType.anyType, + ]); + } + + private static createArraySymbolIteratorAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Array, 'Symbol.iterator', false); + } + + private static createSetSymbolIteratorAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Set, 'Symbol.iterator', false); + } + + private static createMapSymbolIteratorAPI(): DeprecatedAPIInfo { + return new DeprecatedAPIInfo(APIBaseCategory.Map, 'Symbol.iterator', false); + } +} + +export class InteropDeprecatedBuiltInAPICheck implements BaseChecker { + readonly metaData: BaseMetaData = gMetaData; + public rule: Rule; + public defects: Defects[] = []; + public issues: IssueReport[] = []; + private cg: CallGraph; + private dvfg: DVFG; + private dvfgBuilder: DVFGBuilder; + private scene: Scene; + private visited: Set = new Set(); + + public registerMatchers(): MatcherCallback[] { + const matchBuildCb: MatcherCallback = { + matcher: undefined, + callback: this.check, + }; + return [matchBuildCb]; + } + + public check = (scene: Scene): void => { + this.scene = scene; + this.cg = GlobalCallGraphHelper.getCGInstance(scene); + + this.dvfg = new DVFG(this.cg); + this.dvfgBuilder = new DVFGBuilder(this.dvfg, scene); + + for (let arkFile of scene.getFiles()) { + // 此规则仅对arkts1.1进行检查 + if (!(arkFile.getLanguage() === Language.ARKTS1_1)) { + continue; + } + const defaultMethod = arkFile.getDefaultClass().getDefaultArkMethod(); + let globalVarMap: Map = new Map(); + if (defaultMethod) { + this.dvfgBuilder.buildForSingleMethod(defaultMethod); + globalVarMap = getGlobalsDefineInDefaultMethod(defaultMethod); + } + for (let arkClass of arkFile.getClasses()) { + this.processArkClass(arkClass, globalVarMap); + } + for (let namespace of arkFile.getAllNamespacesUnderThisFile()) { + this.processNameSpace(namespace, globalVarMap); + } + } + }; + + public processArkClass(arkClass: ArkClass, globalVarMap: Map): void { + for (let field of arkClass.getFields()) { + this.processClassField(field, globalVarMap); + } + for (let mtd of arkClass.getMethods()) { + this.processArkMethod(mtd, globalVarMap); + } + } + + public processNameSpace(namespace: ArkNamespace, globalVarMap: Map): void { + for (let ns of namespace.getNamespaces()) { + this.processNameSpace(ns, globalVarMap); + } + for (let arkClass of namespace.getClasses()) { + this.processArkClass(arkClass, globalVarMap); + } + } + + public processClassField(field: ArkField, globalVarMap: Map): void { + const stmts = field.getInitializer(); + for (const stmt of stmts) { + const invokeExpr = this.getInvokeExpr(stmt); + if (invokeExpr === null) { + continue; + } + } + } + + public processArkMethod(target: ArkMethod, globalVarMap: Map): void { + const stmts = target.getBody()?.getCfg().getStmts() ?? []; + for (const stmt of stmts) { + // 查找到DeprecatedAPIs中的builtIn的API调用语句为sink点,从该点开始进行逆向数据流分析,分析base是否为arkts1.2中声明的对象实例或其引用 + const targetLocal = this.getTargetLocalOfDeprecatedAPICall(stmt); + if (targetLocal === null) { + continue; + } + + // 从base的最近一次赋值语句开始,使用逆向数据流进行查找 + let checkStmt = this.getLastAssignStmt(targetLocal, stmt); + if (checkStmt === null) { + checkStmt = this.checkTargetLocalAsGlobal(target, stmt, targetLocal, globalVarMap); + } + if (checkStmt === null) { + continue; + } + + if (!this.visited.has(target)) { + this.dvfgBuilder.buildForSingleMethod(target); + this.visited.add(target); + } + + let checkAll = { value: true }; + let visited: Set = new Set(); + if (this.checkFromStmt(checkStmt, globalVarMap, checkAll, visited)) { + this.addIssueReport(stmt, targetLocal); + } + } + } + + private checkTargetLocalAsGlobal(targetMethod: ArkMethod, stmt: Stmt, targetLocal: Local, globalVarMap: Map): Stmt | null { + const globalDefs = globalVarMap.get(targetLocal.getName()); + if (globalDefs === undefined) { + const importInfos = targetMethod.getDeclaringArkClass().getDeclaringArkFile().getImportInfos(); + const importValue = this.isLocalFromImport(targetLocal, importInfos); + if (importValue && importValue.getDeclaringStmt() !== null) { + return importValue.getDeclaringStmt()!; + } + return null; + } + let lastLegalStmtLine = -1; + let lastIllegalStmtLine = -1; + for (const defStmt of globalDefs) { + if (!this.visited.has(targetMethod)) { + this.dvfgBuilder.buildForSingleMethod(targetMethod); + this.visited.add(targetMethod); + } + + let checkAll = { value: true }; + let visited: Set = new Set(); + + const currStmtLine = defStmt.getOriginPositionInfo().getLineNo(); + if (this.checkFromStmt(defStmt, globalVarMap, checkAll, visited)) { + if (currStmtLine > lastIllegalStmtLine) { + lastIllegalStmtLine = currStmtLine; + } + } else { + if (currStmtLine > lastLegalStmtLine) { + lastLegalStmtLine = currStmtLine; + } + } + } + if (lastIllegalStmtLine > lastLegalStmtLine) { + this.addIssueReport(stmt, targetLocal); + } + return null; + } + + private getLastAssignStmt(local: Local, currStmt: Stmt): Stmt | null { + // 获取local变量在currStmt使用语句之前的最近一次赋值/声明语句,未找到表示直接来自于全局变量或import信息,则返回null + const usedStmts = local.getUsedStmts(); + let currLine = currStmt.getOriginPositionInfo().getLineNo(); + let lastAssignStmt = local.getDeclaringStmt(); + for (const stmt of usedStmts) { + if (stmt === currStmt || !(stmt instanceof ArkAssignStmt) || stmt.getLeftOp() !== local) { + continue; + } + const line = stmt.getOriginPositionInfo().getLineNo(); + if (line < currLine) { + lastAssignStmt = stmt; + currLine = line; + } + } + return lastAssignStmt; + } + + private isLocalDefinedInStaticArkTS(local: Local): boolean { + return local.getDeclaringStmt()?.getCfg().getDeclaringMethod().getLanguage() === Language.ARKTS1_2; + } + + // 判断语句是否为废弃API接口的调用语句,若废弃接口仅为一系列重载中的某一种,需要判断这一具体重载形态,若是返回对应需要查找的Local对象,否则返回null + private getTargetLocalOfDeprecatedAPICall(stmt: Stmt): Local | null { + const invokeExpr = this.getInvokeExpr(stmt); + if (invokeExpr === null) { + return null; + } + if (invokeExpr instanceof ArkInstanceInvokeExpr) { + const base = invokeExpr.getBase(); + if (this.isInstanceCallMethodInDeprecatedAPIs(base, stmt, invokeExpr.getMethodSignature(), invokeExpr.getArgs())) { + return base; + } + // instance invoke未匹配到,继续匹配静态调用。Array.from的API调用ArkAnalyzer也表示为ArkInstanceInvokeExpr,因为API定义里没有明确的static标识。 + return this.getTargetValueInStaticInvokeWithDeprecatedAPIs(invokeExpr); + } else if (invokeExpr instanceof ArkPtrInvokeExpr) { + // TODO:可能存在ptr invoke的场景吗? + return null; + } else if (invokeExpr instanceof ArkStaticInvokeExpr) { + return null; + } + return null; + } + + private getInvokeExpr(stmt: Stmt): AbstractInvokeExpr | null { + if (!(stmt instanceof ArkAssignStmt) && !(stmt instanceof ArkInvokeStmt)) { + return null; + } + + if (stmt instanceof ArkInvokeStmt) { + return stmt.getInvokeExpr(); + } + + const rightOp = stmt.getRightOp(); + if (rightOp instanceof AbstractInvokeExpr) { + return rightOp; + } + return null; + } + + private compareParamTypes(apiParams: Type[], callApiParams: MethodParameter[]): boolean { + if (apiParams.length !== callApiParams.length) { + return false; + } + for (let i = 0; i < apiParams.length; i++) { + if (!this.isTypeMatch(apiParams[i], callApiParams[i].getType())) { + return false; + } + } + return true; + } + + private getTargetValueInStaticInvokeWithDeprecatedAPIs(staticInvokeExpr: ArkStaticInvokeExpr): Local | null { + const callApiMethod = staticInvokeExpr.getMethodSignature(); + const callApiClass = callApiMethod.getDeclaringClassSignature(); + for (const api of DeprecatedAPIList.DeprecatedAPIs) { + if (!api.isStatic) { + continue; + } + if (api.name !== callApiMethod.getMethodSubSignature().getMethodName()) { + continue; + } + // Array.from 形式的调用,from方法实际的class为ArrayConstructor + if (api.base !== callApiClass.getClassName() && `${api.base}Constructor` !== callApiClass.getClassName()) { + continue; + } + // 在本条规则检查范围内的static API的调用一定是带参数的,并且其中某个参数即为需要进行进一步查找的value + if (api.params === undefined) { + continue; + } + if (this.compareParamTypes(api.params, callApiMethod.getMethodSubSignature().getParameters())) { + const args = staticInvokeExpr.getArgs(); + // 形参匹配的情况下,进一步比较传入的实参,因为当前废弃接口大多数为去掉any类型的第二个可选参数 + // TODO:这里需要考虑如何做的更通用 + if (args.length !== api.params.length) { + continue; + } + const index = api.targetParamIndex; + // 成功匹配到指定的API后,如果未提供下一步需要查找的目标param的index,则返回null。理论上不应该走到这个分支。 + if (index === undefined) { + logger.error(`Missing targetParamIndex, api: ${api.name}, category ${api.base}`); + return null; + } + + if (args.length <= index) { + logger.error(`Invalid targetParamIndex ${index}, totally invoke args size ${args.length}, api: ${api.name}, category ${api.base}`); + return null; + } + const target = args[index]; + if (target instanceof Local) { + return target; + } + logger.error(`Need to handle non-local target ${target.getType().getTypeString()}`); + return null; + } + } + return null; + } + + private isMatchSymbolIterator(apiName: string, callApiName: string, stmt: Stmt): boolean { + // 对于map[Symbol.iterator]这样的API,这里会存在%0 = Symbol.iterator的操作 + if (apiName !== 'Symbol.iterator' || !callApiName.startsWith('%')) { + return false; + } + const tempLocalDeclaring = stmt.getCfg().getDeclaringMethod().getBody()?.getLocals().get(callApiName)?.getDeclaringStmt(); + if (tempLocalDeclaring && tempLocalDeclaring instanceof ArkAssignStmt) { + const rightOp = tempLocalDeclaring.getRightOp(); + if (!(rightOp instanceof ArkInstanceFieldRef)) { + return false; + } + if (rightOp.getFieldName() === 'iterator' && rightOp.getBase().getName() === 'Symbol') { + return true; + } + } + return false; + } + + private isInstanceCallMethodInDeprecatedAPIs(callBase: Local, stmt: Stmt, callMethod: MethodSignature, args: Value[]): boolean { + const callApiName = callMethod.getMethodSubSignature().getMethodName(); + const callApiParams = callMethod.getMethodSubSignature().getParameters(); + for (const api of DeprecatedAPIList.DeprecatedAPIs) { + // 对于map[Symbol.iterator]这样的API调用,callApiName是临时变量,需要进一步匹配 + if (api.name !== callApiName) { + continue; + } + if (api.isStatic) { + continue; + } + if (!this.isBaseTypeMatchAPIBase(api.base, callBase)) { + continue; + } + + // Array concat API ArkAnalyzer当前无法很好处理...items形式的入参,此处作为特例处理 + if (api.name === 'concat') { + return this.isMatchArrayConcatAPI(args); + } + + const apiParams = api.params; + if (apiParams === undefined) { + return true; + } + let allParamTypeMatch = true; + if (apiParams.length !== callApiParams.length) { + allParamTypeMatch = false; + } else { + for (let i = 0; i < apiParams.length; i++) { + if (!this.isTypeMatch(apiParams[i], callApiParams[i].getType())) { + allParamTypeMatch = false; + break; + } + } + } + + if (allParamTypeMatch) { + // 形参匹配的情况下,进一步比较传入的实参,因为当前废弃接口大多数为去掉any类型的第二个可选参数 + // TODO:这里需要考虑如何做的更通用 + if (args.length !== apiParams.length) { + continue; + } + return true; + } + // 形参类型不匹配的情形,可能是由于ArkAnalyzer的类型推导未能找到正确的API,需要根据实参类型进行二次匹配 + if (apiParams.length !== args.length) { + continue; + } + allParamTypeMatch = true; + for (let i = 0; i < apiParams.length; i++) { + // 对于lambda函数作为参数类型,此处不严格校验lambda的参数类型,仅判断是否为FunctionType + if (apiParams[i] instanceof FunctionType && args[i].getType() instanceof FunctionType) { + continue; + } + if (!this.isTypeMatch(apiParams[i], args[i].getType())) { + allParamTypeMatch = false; + break; + } + } + if (allParamTypeMatch) { + return true; + } + } + return false; + } + + // 判断入参是否都为数组,不允许有单个元素 + private isMatchArrayConcatAPI(args: Value[]): boolean { + for (const arg of args) { + if (!(arg.getType() instanceof ArrayType)) { + return true; + } + } + return false; + } + + private isTypeMatch(apiType: Type, callApiType: Type): boolean { + const apiTypeStr = apiType.getTypeString(); + const callApiTypeStr = callApiType.getTypeString(); + if (callApiType instanceof FunctionType && apiType instanceof FunctionType) { + // 若类型为FunctionType,仅需匹配string中的形参部分 + const regex = /\(([^()]*)\)/; + const apiMatch = apiTypeStr.match(regex); + const callApiMatch = callApiTypeStr.match(regex); + if (apiMatch === null || callApiMatch === null) { + return false; + } + return apiMatch[0] === callApiMatch[0]; + } else if (callApiType instanceof ClassType && apiType instanceof ClassType) { + // 若类型为FunctionType,仅需匹配class name,因为apiTypeStr类型推导后有可能为@%unk/%unk: ArrayLike,而callApiTypeStr有明确的declaring file + return callApiType.getClassSignature().getClassName() === apiType.getClassSignature().getClassName(); + } else if (apiType instanceof AnyType) { + return true; + } else { + // 其他场景需严格判断字符串相等 + return apiTypeStr === callApiTypeStr; + } + } + + private isBaseTypeMatchAPIBase(apiBase: APIBaseCategory, callBase: Local): boolean { + if (apiBase === APIBaseCategory.Array && callBase.getType() instanceof ArrayType) { + return true; + } + if (apiBase === APIBaseCategory.Map) { + const callBaseType = callBase.getType(); + return callBaseType instanceof ClassType && callBaseType.getClassSignature().getClassName() === 'Map'; + } + if (apiBase === APIBaseCategory.Set) { + const callBaseType = callBase.getType(); + return callBaseType instanceof ClassType && callBaseType.getClassSignature().getClassName() === 'Set'; + } + return false; + } + + private checkFromStmt(stmt: Stmt, globalVarMap: Map, checkAll: { value: boolean }, visited: Set, depth: number = 0): boolean { + if (depth > CALL_DEPTH_LIMIT) { + checkAll.value = false; + return false; + } + const node = this.dvfg.getOrNewDVFGNode(stmt); + let worklist: DVFGNode[] = [node]; + while (worklist.length > 0) { + const current = worklist.shift()!; + const currentStmt = current.getStmt(); + if (visited.has(currentStmt)) { + continue; + } + visited.add(currentStmt); + + if (this.isLeftOpDefinedInStaticArkTS(currentStmt)) { + return true; + } + + const gv = this.isRightOpGlobalVar(currentStmt); + if (gv) { + const globalDefs = globalVarMap.get(gv.getName()); + if (globalDefs === undefined) { + const importInfos = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile().getImportInfos(); + const importValue = this.isLocalFromImport(gv, importInfos); + if (importValue && importValue.getDeclaringStmt() !== null) { + worklist.push(this.dvfg.getOrNewDVFGNode(importValue.getDeclaringStmt()!)); + } + } else { + globalDefs.forEach(d => worklist.push(this.dvfg.getOrNewDVFGNode(d))); + } + continue; + } + + const callsite = this.cg.getCallSiteByStmt(currentStmt); + for (const cs of callsite) { + const declaringMtd = this.cg.getArkMethodByFuncID(cs.calleeFuncID); + if (!declaringMtd || !declaringMtd.getCfg()) { + continue; + } + if (!this.visited.has(declaringMtd)) { + this.dvfgBuilder.buildForSingleMethod(declaringMtd); + this.visited.add(declaringMtd); + } + const returnStmts = declaringMtd.getReturnStmt(); + for (const stmt of returnStmts) { + const res = this.checkFromStmt(stmt, globalVarMap, checkAll, visited, depth + 1); + if (res) { + return true; + } + } + } + const paramRef = this.isFromParameter(currentStmt); + if (paramRef) { + const paramIdx = paramRef.getIndex(); + const callsites = this.cg.getInvokeStmtByMethod(currentStmt.getCfg().getDeclaringMethod().getSignature()); + this.processCallsites(callsites); + const argDefs = this.collectArgDefs(paramIdx, callsites); + for (const stmt of argDefs) { + const res = this.checkFromStmt(stmt, globalVarMap, checkAll, visited, depth + 1); + if (res) { + return true; + } + } + } + current.getIncomingEdge().forEach(e => worklist.push(e.getSrcNode() as DVFGNode)); + } + return false; + } + + private isRightOpGlobalVar(stmt: Stmt): Local | undefined { + if (stmt instanceof ArkAssignStmt) { + const rightOp = stmt.getRightOp(); + if (rightOp instanceof Local && !rightOp.getDeclaringStmt()) { + return rightOp; + } + } + return undefined; + } + + private isLocalFromImport(local: Local, importInfos: ImportInfo[]): Local | undefined { + for (const importInfo of importInfos) { + if (importInfo.getImportClauseName() === local.getName()) { + const exportInfo = importInfo.getLazyExportInfo(); + if (exportInfo === null) { + return undefined; + } + const arkExport = exportInfo.getArkExport(); + if (arkExport === null || arkExport === undefined) { + return undefined; + } + if (!(arkExport instanceof Local)) { + return undefined; + } + return arkExport; + } + } + return undefined; + } + + private processCallsites(callsites: Stmt[]): void { + callsites.forEach(cs => { + const declaringMtd = cs.getCfg().getDeclaringMethod(); + if (!this.visited.has(declaringMtd)) { + this.dvfgBuilder.buildForSingleMethod(declaringMtd); + this.visited.add(declaringMtd); + } + }); + } + + // 判断语句是否为赋值语句,且左值的定义来自于ArkTS1.2 + private isLeftOpDefinedInStaticArkTS(stmt: Stmt): boolean { + if (!(stmt instanceof ArkAssignStmt)) { + return false; + } + const leftOp = stmt.getLeftOp(); + if (!(leftOp instanceof Local)) { + return false; + } + return this.isLocalDefinedInStaticArkTS(leftOp); + } + + private isFromParameter(stmt: Stmt): ArkParameterRef | undefined { + if (!(stmt instanceof ArkAssignStmt)) { + return undefined; + } + const rightOp = stmt.getRightOp(); + if (rightOp instanceof ArkParameterRef) { + return rightOp; + } + return undefined; + } + + private collectArgDefs(argIdx: number, callsites: Stmt[]): Stmt[] { + const getKey = (v: Value): Value | FieldSignature => { + return v instanceof ArkInstanceFieldRef ? v.getFieldSignature() : v; + }; + return callsites.flatMap(callsite => { + const target: Value | FieldSignature = getKey(callsite.getInvokeExpr()!.getArg(argIdx)); + let refs = Array.from(this.dvfg.getOrNewDVFGNode(callsite).getIncomingEdge()) + .map(e => (e.getSrcNode() as DVFGNode).getStmt()) + .filter(s => { + return s instanceof ArkAssignStmt && target === getKey(s.getLeftOp()); + }); + // 以上步骤未找到defs语句,说明入参变量来源自import信息 + if (refs.length === 0 && target instanceof Local) { + const importInfos = callsite.getCfg().getDeclaringMethod().getDeclaringArkFile().getImportInfos(); + const importValue = this.isLocalFromImport(target, importInfos); + if (importValue && importValue.getDeclaringStmt() !== null) { + return importValue.getDeclaringStmt()!; + } + } + return refs; + }); + } + + private addIssueReport(stmt: Stmt, operand: Value): void { + const severity = this.rule.alert ?? this.metaData.severity; + const warnInfo = this.getLineAndColumn(stmt, operand); + const problem = 'builtin-api'; + const desc = `Builtin API is not support in ArkTS1.2 (${this.rule.ruleId.replace('@migration/', '')})`; + + let defects = new Defects( + warnInfo.line, + warnInfo.startCol, + warnInfo.endCol, + problem, + desc, + severity, + this.rule.ruleId, + warnInfo.filePath, + this.metaData.ruleDocPath, + true, + false, + false + ); + this.issues.push(new IssueReport(defects, undefined)); + } + + private getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); + const originPosition = stmt.getOperandOriginalPosition(operand); + if (arkFile && originPosition) { + const originPath = arkFile.getFilePath(); + const line = originPosition.getFirstLine(); + const startCol = originPosition.getFirstCol(); + const endCol = startCol; + return { line, startCol, endCol, filePath: originPath }; + } else { + logger.debug('ArkFile is null.'); + } + return { line: -1, startCol: -1, endCol: -1, filePath: '' }; + } +} diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts index 3b912361f2bb7896b526e8a434388ddb7de83703..16ea7584bcb4d8889287c3486c4da61c259c7eca 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropJSModifyPropertyCheck.ts @@ -276,10 +276,8 @@ export class InteropJSModifyPropertyCheck implements BaseChecker { } if (file) { return file.getLanguage(); - } else { - logger.error(`fail to identify which file the type definition ${type.toString()} is in.`); - return Language.UNKNOWN; } + return Language.UNKNOWN; } private reportIssue(problemStmt: Stmt) { @@ -289,7 +287,7 @@ export class InteropJSModifyPropertyCheck implements BaseChecker { const desc = `${this.metaData.description} (${RULE_ID})`; const severity = this.metaData.severity; const ruleId = this.rule.ruleId; - const filePath = problemStmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile()?.getFilePath() ?? ''; + const filePath = problemStmt.getCfg().getDeclaringMethod().getDeclaringArkFile()?.getFilePath() ?? ''; const defeats = new Defects( line, column, diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropS2DObjectLiteralsCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropS2DObjectLiteralsCheck.ts new file mode 100644 index 0000000000000000000000000000000000000000..79c14788bdc77d356e06091829b11d10c47f7a83 --- /dev/null +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropS2DObjectLiteralsCheck.ts @@ -0,0 +1,347 @@ +/* + * 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 { + ArkMethod, + ArkAssignStmt, + Stmt, + Scene, + Value, + ArkInstanceFieldRef, + ClassType, + ArkInvokeStmt, + AbstractInvokeExpr, + ArkField, + ArkReturnStmt, +} from 'arkanalyzer/lib'; +import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; +import { BaseChecker, BaseMetaData } from '../BaseChecker'; +import { Rule, Defects, MatcherCallback, MatcherTypes, MethodMatcher } from '../../Index'; +import { IssueReport } from '../../model/Defects'; +import { ArkClass, ClassCategory } from 'arkanalyzer/lib/core/model/ArkClass'; +import { Language } from 'arkanalyzer/lib/core/model/ArkFile'; +import { getLanguageStr, getLineAndColumn } from './Utils'; + +const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'InteropS2DObjectLiteralCheck'); +const gMetaData: BaseMetaData = { + severity: 1, + ruleDocPath: '', + description: '', +}; + +const s2dRuleId: string = 'arkts-interop-s2d-object-literal'; + +type IssueData = { + stmt: Stmt; + value: Value; +}; + +export class InteropS2DObjectLiteralCheck implements BaseChecker { + private scene: Scene; + readonly metaData: BaseMetaData = gMetaData; + public rule: Rule; + public defects: Defects[] = []; + public issues: IssueReport[] = []; + + private methodMatcher: MethodMatcher = { + matcherType: MatcherTypes.METHOD, + }; + + public registerMatchers(): MatcherCallback[] { + const methodMatcher: MatcherCallback = { + matcher: this.methodMatcher, + callback: this.check, + }; + return [methodMatcher]; + } + + public check = (arkMethod: ArkMethod): void => { + this.scene = arkMethod.getDeclaringArkFile().getScene(); + + if (arkMethod.getLanguage() !== Language.ARKTS1_1) { + return; + } + // 检测的sink点为赋值语句,且左值的类型注解明确为1.2的class或者包含1.2的class的更复杂数据结构 + const stmts = arkMethod.getBody()?.getCfg().getStmts() ?? []; + // 检查所有语句 + // 1. 对于赋值语句,检查左边是否为arkts1.2的class类型或某个field为arkts1.2的class类型,右边对象或对应属性是否用arkts1.1的object litral赋值 + // 2. 对于函数调用,可能为invoke语句或赋值语句的右值为invoke表达式,检查入参是否存在如上的情况 + for (const stmt of stmts) { + if (stmt instanceof ArkAssignStmt) { + this.checkAssignWithObjectLiteral(stmt, arkMethod); + if (stmt.getRightOp() instanceof AbstractInvokeExpr) { + this.checkInvokeWithObjectLiteral(stmt, arkMethod); + } + } else if (stmt instanceof ArkInvokeStmt) { + this.checkInvokeWithObjectLiteral(stmt, arkMethod); + } + } + // 检查函数的返回值,若函数签名中返回类型声明是否为arkts1.2的class类型或某个field为arkts1.2的class类型,且实际返回对象或对应属性是否为arkts1.1的object litral + this.checkReturnWithObjectLiteral(arkMethod); + }; + + private getClassWithType(checkType: ClassType): ArkClass | null { + return this.scene.getClass(checkType.getClassSignature()); + } + + private isClassFromEtsStatic(clazz: ArkClass): boolean { + return clazz.getLanguage() === Language.ARKTS1_2 && clazz.getCategory() !== ClassCategory.OBJECT; + } + + private isObjectLiteralFromEtsDynamic(clazz: ArkClass): boolean { + return clazz.getLanguage() === Language.ARKTS1_1 && clazz.getCategory() === ClassCategory.OBJECT; + } + + private checkAssignWithObjectLiteral(stmt: ArkAssignStmt, target: ArkMethod): void { + const leftOpType = stmt.getLeftOp().getType(); + if (!(leftOpType instanceof ClassType)) { + return; + } + const leftTypeClass = this.getClassWithType(leftOpType); + if (leftTypeClass === null) { + logger.debug(`Failed to find class of type ${leftOpType.toString()}`); + return; + } + if (this.isClassFromEtsStatic(leftTypeClass)) { + const rightOpType = stmt.getRightOp().getType(); + if (!(rightOpType instanceof ClassType)) { + return; + } + const rightTypeClass = this.getClassWithType(rightOpType); + if (rightTypeClass === null) { + logger.debug(`Failed to find class of type ${rightOpType.toString()}`); + return; + } + if (this.isObjectLiteralFromEtsDynamic(rightTypeClass)) { + this.addIssueReport(stmt, stmt.getRightOp()); + return; + } + } + let results: IssueData[] = []; + this.checkAllClassFieldWithValue(stmt, stmt.getRightOp(), leftTypeClass, results); + for (const result of results) { + this.addIssueReport(result.stmt, result.value); + } + } + + private checkInvokeWithObjectLiteral(stmt: ArkInvokeStmt | ArkAssignStmt, target: ArkMethod): void { + let invokeExpr: AbstractInvokeExpr; + if (stmt instanceof ArkInvokeStmt) { + invokeExpr = stmt.getInvokeExpr(); + } else { + const rightOp = stmt.getRightOp(); + if (!(rightOp instanceof AbstractInvokeExpr)) { + return; + } + invokeExpr = rightOp; + } + const method = this.scene.getMethod(invokeExpr.getMethodSignature()); + if (method === null) { + logger.debug(`Failed to find method in invoke expr, method: ${invokeExpr.getMethodSignature().toString()}`); + return; + } + for (const [index, param] of method.getParameters().entries()) { + const paramType = param.getType(); + if (!(paramType instanceof ClassType)) { + continue; + } + const paramTypeClass = this.getClassWithType(paramType); + if (paramTypeClass === null) { + logger.debug(`Failed to find class of method param type ${paramType.toString()}, method: ${method.getSignature().toString()}`); + continue; + } + if (index >= invokeExpr.getArgs().length) { + logger.debug(`Failed to find param with index ${index} of method: ${method.getSignature().toString()}`); + continue; + } + const arg = invokeExpr.getArg(index); + if (this.isClassFromEtsStatic(paramTypeClass)) { + const argType = arg.getType(); + if (!(argType instanceof ClassType)) { + continue; + } + const argTypeClass = this.getClassWithType(argType); + if (argTypeClass === null) { + logger.debug(`Failed to find class of invoke arg type ${argType.toString()}, method: ${method.getSignature().toString()}`); + continue; + } + if (this.isObjectLiteralFromEtsDynamic(argTypeClass)) { + this.addIssueReport(stmt, arg); + return; + } + } + let results: IssueData[] = []; + this.checkAllClassFieldWithValue(stmt, arg, paramTypeClass, results); + for (const result of results) { + this.addIssueReport(result.stmt, result.value); + } + } + } + + private checkReturnWithObjectLiteral(target: ArkMethod): void { + // 构造函数的返回值一定是当前class本身,其各field和method已在其他地方进行检查,这里无需检查构造函数的返回值 + if (target.getName() === 'constructor') { + return; + } + const returnType = target.getReturnType(); + if (!(returnType instanceof ClassType)) { + return; + } + const returnTypeClass = this.getClassWithType(returnType); + if (returnTypeClass === null) { + logger.debug(`Failed to find method of return type ${returnType.toString()}, method ${target.getSignature().toString()}`); + return; + } + const returnStmts = target.getReturnStmt(); + if (this.isClassFromEtsStatic(returnTypeClass)) { + for (const returnStmt of returnStmts) { + if (!(returnStmt instanceof ArkReturnStmt)) { + continue; + } + const valueType = returnStmt.getOp().getType(); + if (!(valueType instanceof ClassType)) { + continue; + } + const valueTypeClass = this.getClassWithType(valueType); + if (valueTypeClass === null) { + logger.debug(`Failed to find method of return value type ${valueType.toString()}, method ${target.getSignature().toString()}`); + continue; + } + if (this.isObjectLiteralFromEtsDynamic(valueTypeClass)) { + this.addIssueReport(returnStmt, returnStmt.getOp()); + } + } + return; + } + + for (const returnStmt of returnStmts) { + if (!(returnStmt instanceof ArkReturnStmt)) { + continue; + } + let results: IssueData[] = []; + this.checkAllClassFieldWithValue(returnStmt, returnStmt.getOp(), returnTypeClass, results); + if (results.length > 0) { + this.addIssueReport(returnStmt, returnStmt.getOp()); + } + } + } + + private checkAllClassFieldWithValue(sinkStmt: Stmt, val: Value, needCheckClass: ArkClass, result: IssueData[], checkedTypes?: Set): void { + let visited: Set = checkedTypes ?? new Set(); + if (visited.has(needCheckClass.getSignature().toString())) { + return; + } + visited.add(needCheckClass.getSignature().toString()); + for (const field of needCheckClass.getFields()) { + const fieldType = field.getType(); + if (!(fieldType instanceof ClassType)) { + continue; + } + const fieldTypeClass = this.getClassWithType(fieldType); + if (fieldTypeClass === null) { + logger.debug( + `Failed to find class of type ${fieldType.toString()} of field: ${field.getName()}, class ${needCheckClass.getSignature().toString()}}` + ); + continue; + } + const fieldInitializers = this.getFieldInitializersWithValue(field, val); + const fieldAssignStmt = this.getFieldAssignStmtInInitializers(field, fieldInitializers); + if (fieldAssignStmt === null) { + continue; + } + if (this.isClassFromEtsStatic(fieldTypeClass)) { + const rightOpType = fieldAssignStmt.getRightOp().getType(); + if (!(rightOpType instanceof ClassType)) { + continue; + } + const rightOpTypeClass = this.getClassWithType(rightOpType); + if (rightOpTypeClass === null) { + logger.debug( + `Failed to find class of type ${rightOpType.toString()} of field initializer, field: ${field.getName()}, class ${needCheckClass.getSignature().toString()}}` + ); + continue; + } + if (this.isObjectLiteralFromEtsDynamic(rightOpTypeClass)) { + result.push({ stmt: sinkStmt, value: val }); + continue; + } + continue; + } + this.checkAllClassFieldWithValue(fieldAssignStmt, fieldAssignStmt.getRightOp(), fieldTypeClass, result, visited); + } + } + + private getFieldAssignStmtInInitializers(field: ArkField, fieldInitializers: Stmt[]): ArkAssignStmt | null { + for (const stmt of fieldInitializers) { + if (!(stmt instanceof ArkAssignStmt)) { + continue; + } + const leftOp = stmt.getLeftOp(); + if (!(leftOp instanceof ArkInstanceFieldRef)) { + continue; + } + if (leftOp.getFieldName() === field.getName()) { + return stmt; + } + } + return null; + } + + // 对于object literal(主要是多层嵌套场景),根据需要查找的field的名字,获取其对应的内部嵌套class的初始化语句 + private getFieldInitializersWithValue(leftField: ArkField, val: Value): Stmt[] { + const res: Stmt[] = []; + const rightOpType = val.getType(); + if (!(rightOpType instanceof ClassType)) { + return res; + } + const rightOpTypeClass = this.getClassWithType(rightOpType); + if (rightOpTypeClass === null) { + logger.debug(`Failed to find class of type ${rightOpType.toString()} of field: ${leftField.getSignature().toString()}`); + return res; + } + for (const field of rightOpTypeClass.getFields()) { + if (field.getName() === leftField.getName()) { + return field.getInitializer(); + } + } + return res; + } + + private addIssueReport(stmt: Stmt, operand: Value): void { + const severity = this.metaData.severity; + let warnInfo = getLineAndColumn(stmt, operand); + let targetLan1 = getLanguageStr(Language.ARKTS1_1); + let targetLan2 = getLanguageStr(Language.ARKTS1_2); + + const problem = 'Interop'; + const desc = `In ${targetLan1}, it is not allowed to create object literal of type from ${targetLan2} (${s2dRuleId})`; + + let defects = new Defects( + warnInfo.line, + warnInfo.startCol, + warnInfo.endCol, + problem, + desc, + severity, + this.rule.ruleId, + warnInfo.filePath, + this.metaData.ruleDocPath, + true, + false, + false + ); + this.issues.push(new IssueReport(defects, undefined)); + } +} diff --git a/ets2panda/linter/homecheck/src/checker/migration/ModifyStateVarCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/ModifyStateVarCheck.ts index c25cc59611ec6e7b8182054beace616da724ba7a..dfabd40fe05228e763bbd99a440a70c3072378db 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/ModifyStateVarCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/ModifyStateVarCheck.ts @@ -171,7 +171,7 @@ export class ModifyStateVarCheck implements BaseChecker { } private getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); diff --git a/ets2panda/linter/homecheck/src/checker/migration/NoTSLikeAsCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/NoTSLikeAsCheck.ts index f45c63723cfb7b492c0972d4079cd9d6ef5d6740..3e6f594aa1aff68dc4c3412b80abd932b6702e5f 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/NoTSLikeAsCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/NoTSLikeAsCheck.ts @@ -37,6 +37,13 @@ import { BasicBlock, ArkIfStmt, ArkUnopExpr, + RelationalBinaryOperator, + LineColPosition, + UnaryOperator, + ArkNormalBinopExpr, + NormalBinaryOperator, + AbstractFieldRef, + ClassSignature, } from 'arkanalyzer/lib'; import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; import { BaseChecker, BaseMetaData } from '../BaseChecker'; @@ -47,6 +54,7 @@ import { CALL_DEPTH_LIMIT, getGlobalsDefineInDefaultMethod, GlobalCallGraphHelpe import { WarnInfo } from '../../utils/common/Utils'; import { ClassCategory } from 'arkanalyzer/lib/core/model/ArkClass'; import { Language } from 'arkanalyzer/lib/core/model/ArkFile'; +import { BooleanConstant } from 'arkanalyzer/lib/core/base/Constant'; const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'NoTSLikeAsCheck'); const gMetaData: BaseMetaData = { @@ -55,6 +63,12 @@ const gMetaData: BaseMetaData = { description: '', }; +enum TypeAssuranceCondition { + Positive, + Negative, + NotExist, +} + export class NoTSLikeAsCheck implements BaseChecker { readonly metaData: BaseMetaData = gMetaData; public rule: Rule; @@ -181,21 +195,19 @@ export class NoTSLikeAsCheck implements BaseChecker { return false; } for (const block of cfg.getBlocks()) { - // 这里仅判断了cast op是否进行了instanceof判断,如果op是由op1赋值,op1进行了instanceof判断,此处不认为是做了有效检查 - // TODO: 还需进行复杂条件中包含类型守卫判断的情况,涉及&&,||等的复合 - const positiveCheck = this.isCastExprWithTypeAssurancePositive(block, castExpr); - const negativeCheck = this.isCastExprWithTypeAssuranceNegative(block, castExpr); - if (!(positiveCheck || negativeCheck)) { + // 这里仅判断了cast op是否进行了instanceof判断,如果op是由op1赋值,op1进行了instanceof判断,此处不认为是做了有效检查,因为此赋值链可能很长且中途发生类型变化,极易判断错误 + const checkRes = this.checkTypeAssuranceInBasicBlock(block, castExpr); + if (checkRes === TypeAssuranceCondition.NotExist) { continue; } let checkedBB: Set = new Set(); let needCheckBB: number[] = []; checkedBB.add(block.getId()); const allSuccessors = block.getSuccessors(); - if (allSuccessors.length > 0 && positiveCheck) { + if (allSuccessors.length > 0 && checkRes === TypeAssuranceCondition.Positive) { needCheckBB.push(allSuccessors[0].getId()); } - if (allSuccessors.length > 1 && negativeCheck) { + if (allSuccessors.length > 1 && checkRes === TypeAssuranceCondition.Negative) { needCheckBB.push(allSuccessors[1].getId()); } while (needCheckBB.length > 0) { @@ -221,26 +233,7 @@ export class NoTSLikeAsCheck implements BaseChecker { return false; } - private isStmtInBlock(stmt: Stmt, block: BasicBlock): boolean { - for (const s of block.getStmts()) { - if (s === stmt) { - return true; - } - } - return false; - } - - private getBlockWithId(id: number, cfg: Cfg): BasicBlock | null { - const blocks = cfg.getBlocks(); - for (const bb of blocks) { - if (bb.getId() === id) { - return bb; - } - } - return null; - } - - private isCastExprWithTypeAssurancePositive(bb: BasicBlock, castExpr: ArkCastExpr): boolean { + private checkTypeAssuranceInBasicBlock(bb: BasicBlock, castExpr: ArkCastExpr): TypeAssuranceCondition { for (const stmt of bb.getStmts()) { if (!(stmt instanceof ArkIfStmt)) { continue; @@ -248,98 +241,109 @@ export class NoTSLikeAsCheck implements BaseChecker { const conditionExpr = stmt.getConditionExpr(); const op1 = conditionExpr.getOp1(); const op2 = conditionExpr.getOp2(); - if (op1 instanceof Local) { - const declareStmt = op1.getDeclaringStmt(); - if (declareStmt !== null && this.isStmtWithTypeAssurancePositive(declareStmt, castExpr)) { - return true; - } - } - if (op2 instanceof Local) { - const declareStmt = op2.getDeclaringStmt(); - if (declareStmt !== null && this.isStmtWithTypeAssurancePositive(declareStmt, castExpr)) { - return true; - } + const operator = conditionExpr.getOperator(); + // 对于if (i instanceof A)这种条件语句,op1总是临时变量,op2总是false,操作符总是!= + if (!(op1 instanceof Local && op2 instanceof BooleanConstant && op2.getValue() === 'false' && operator === RelationalBinaryOperator.InEquality)) { + break; } + return this.checkTypeAssuranceWithLocal(op1, castExpr, stmt.getOriginPositionInfo(), true); } - return false; + return TypeAssuranceCondition.NotExist; } - private isCastExprWithTypeAssuranceNegative(bb: BasicBlock, castExpr: ArkCastExpr): boolean { - for (const stmt of bb.getStmts()) { - if (!(stmt instanceof ArkIfStmt)) { - continue; + private checkTypeAssuranceWithLocal(operand: Local, castExpr: ArkCastExpr, ifStmtPos: LineColPosition, shouldBe: boolean): TypeAssuranceCondition { + const declaringStmt = operand.getDeclaringStmt(); + if (declaringStmt === null) { + return TypeAssuranceCondition.NotExist; + } + // if语句中的所有条件遵从三地址码原则拆分成多个语句时,所有语句的位置信息是一致的,不一致时表示是条件语句之前的赋值或声明情况,不在本判断范围内 + const stmtPos = declaringStmt.getOriginPositionInfo(); + if (stmtPos.getLineNo() !== ifStmtPos.getLineNo() || stmtPos.getColNo() !== ifStmtPos.getColNo()) { + return TypeAssuranceCondition.NotExist; + } + if (!(declaringStmt instanceof ArkAssignStmt)) { + return TypeAssuranceCondition.NotExist; + } + const rightOp = declaringStmt.getRightOp(); + if (rightOp instanceof ArkInstanceOfExpr) { + if (this.isTypeAssuranceMatchCast(rightOp, castExpr)) { + if (shouldBe) { + return TypeAssuranceCondition.Positive; + } else { + return TypeAssuranceCondition.Negative; + } } - const conditionExpr = stmt.getConditionExpr(); - const op1 = conditionExpr.getOp1(); - const op2 = conditionExpr.getOp2(); - if (op1 instanceof Local) { - const declareStmt = op1.getDeclaringStmt(); - if (declareStmt !== null && this.isStmtWithTypeAssuranceNegative(declareStmt, castExpr)) { - return true; + return TypeAssuranceCondition.NotExist; + } + if (rightOp instanceof ArkUnopExpr && rightOp.getOperator() === UnaryOperator.LogicalNot) { + const unaryOp = rightOp.getOp(); + if (unaryOp instanceof Local) { + return this.checkTypeAssuranceWithLocal(unaryOp, castExpr, ifStmtPos, !shouldBe); + } + return TypeAssuranceCondition.NotExist; + } + if (rightOp instanceof ArkNormalBinopExpr) { + const op1 = rightOp.getOp1(); + const op2 = rightOp.getOp2(); + const operator = rightOp.getOperator(); + // 这里仅判断&&和||两种逻辑运算符的场景,其他场景在包含类型守卫判断的条件语句中不常见,暂不考虑 + let res: TypeAssuranceCondition; + if (operator === NormalBinaryOperator.LogicalAnd) { + if (op1 instanceof Local) { + res = this.checkTypeAssuranceWithLocal(op1, castExpr, ifStmtPos, shouldBe); + if (res !== TypeAssuranceCondition.NotExist) { + return res; + } + } + if (op2 instanceof Local) { + res = this.checkTypeAssuranceWithLocal(op2, castExpr, ifStmtPos, shouldBe); + if (res !== TypeAssuranceCondition.NotExist) { + return res; + } } + return TypeAssuranceCondition.NotExist; } - if (op2 instanceof Local) { - const declareStmt = op2.getDeclaringStmt(); - if (declareStmt !== null && this.isStmtWithTypeAssuranceNegative(declareStmt, castExpr)) { - return true; + if (operator === NormalBinaryOperator.LogicalOr) { + // a or b,不论a或b里是类型守卫判断,均无法保证分支中的类型明确 + if (shouldBe) { + return TypeAssuranceCondition.NotExist; } } } - return false; + return TypeAssuranceCondition.NotExist; } - private isStmtWithTypeAssurancePositive(declareStmt: Stmt, castExpr: ArkCastExpr): boolean { - if (!(declareStmt instanceof ArkAssignStmt)) { - return false; - } - const rightOp = declareStmt.getRightOp(); - if (!(rightOp instanceof ArkInstanceOfExpr)) { - return false; - } + private isTypeAssuranceMatchCast(instanceOfExpr: ArkInstanceOfExpr, castExpr: ArkCastExpr): boolean { const castOp = castExpr.getOp(); const castType = castExpr.getType(); - const instanceofType = rightOp.getCheckType(); + const instanceofType = instanceOfExpr.getCheckType(); if (castType.getTypeString() !== instanceofType.getTypeString()) { return false; } - const instanceofOp = rightOp.getOp(); + const instanceofOp = instanceOfExpr.getOp(); if (!(castOp instanceof Local && instanceofOp instanceof Local)) { return false; } return castOp.getName() === instanceofOp.getName(); } - private isStmtWithTypeAssuranceNegative(declareStmt: Stmt, castExpr: ArkCastExpr): boolean { - if (!(declareStmt instanceof ArkAssignStmt)) { - return false; - } - const rightOp = declareStmt.getRightOp(); - if (!(rightOp instanceof ArkUnopExpr && rightOp.getOperator() === '!')) { - return false; - } - const unaryOp = rightOp.getOp(); - if (!(unaryOp instanceof Local)) { - return false; - } - const unaryOpDeclareStmt = unaryOp.getDeclaringStmt(); - if (unaryOpDeclareStmt === null || !(unaryOpDeclareStmt instanceof ArkAssignStmt)) { - return false; - } - const unaryOpRightOp = unaryOpDeclareStmt.getRightOp(); - if (!(unaryOpRightOp instanceof ArkInstanceOfExpr)) { - return false; - } - const castOp = castExpr.getOp(); - const castType = castExpr.getType(); - const instanceofType = unaryOpRightOp.getCheckType(); - if (castType.getTypeString() !== instanceofType.getTypeString()) { - return false; + private isStmtInBlock(stmt: Stmt, block: BasicBlock): boolean { + for (const s of block.getStmts()) { + if (s === stmt) { + return true; + } } - const instanceofOp = unaryOpRightOp.getOp(); - if (!(castOp instanceof Local && instanceofOp instanceof Local)) { - return false; + return false; + } + + private getBlockWithId(id: number, cfg: Cfg): BasicBlock | null { + const blocks = cfg.getBlocks(); + for (const bb of blocks) { + if (bb.getId() === id) { + return bb; + } } - return castOp.getName() === instanceofOp.getName(); + return null; } private checkFromStmt( @@ -366,6 +370,11 @@ export class NoTSLikeAsCheck implements BaseChecker { if (this.isWithInterfaceAnnotation(currentStmt, scene)) { return currentStmt; } + + const fieldDeclareStmt = this.isCastOpFieldWithInterfaceType(currentStmt, scene); + if (fieldDeclareStmt) { + return fieldDeclareStmt; + } const gv = this.checkIfCastOpIsGlobalVar(currentStmt); if (gv) { const globalDefs = globalVarMap.get(gv.getName()); @@ -401,9 +410,7 @@ export class NoTSLikeAsCheck implements BaseChecker { const paramRef = this.isFromParameter(currentStmt); if (paramRef) { const paramIdx = paramRef.getIndex(); - const callsites = this.cg.getInvokeStmtByMethod( - currentStmt.getCfg().getDeclaringMethod().getSignature() - ); + const callsites = this.cg.getInvokeStmtByMethod(currentStmt.getCfg().getDeclaringMethod().getSignature()); this.processCallsites(callsites); const argDefs = this.collectArgDefs(paramIdx, callsites); for (const stmt of argDefs) { @@ -418,6 +425,34 @@ export class NoTSLikeAsCheck implements BaseChecker { return null; } + private isCastOpFieldWithInterfaceType(stmt: Stmt, scene: Scene): Stmt | undefined { + const obj = this.getCastOp(stmt); + if (obj === null || !(obj instanceof Local)) { + return undefined; + } + const declaringStmt = obj.getDeclaringStmt(); + if (declaringStmt === null || !(declaringStmt instanceof ArkAssignStmt)) { + return undefined; + } + const rightOp = declaringStmt.getRightOp(); + if (!(rightOp instanceof AbstractFieldRef)) { + return undefined; + } + const fieldDeclaring = rightOp.getFieldSignature().getDeclaringSignature(); + if (fieldDeclaring instanceof ClassSignature) { + const field = scene.getClass(fieldDeclaring)?.getField(rightOp.getFieldSignature()); + if (!field) { + return undefined; + } + const fieldInitializer = field.getInitializer(); + const lastStmt = fieldInitializer[fieldInitializer.length - 1]; + if (this.isWithInterfaceAnnotation(lastStmt, scene)) { + return lastStmt; + } + } + return undefined; + } + private checkIfCastOpIsGlobalVar(stmt: Stmt): Local | undefined { const obj = this.getCastOp(stmt); if (obj instanceof Local && !obj.getDeclaringStmt()) { @@ -568,7 +603,7 @@ export class NoTSLikeAsCheck implements BaseChecker { } private getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); diff --git a/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts index 66a5c66380b92443cde465bcf577ad4e05791028..b582c90aaf7befd5ec9c52e4dd94af836da2f2dc 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/ObjectLiteralCheck.ts @@ -68,7 +68,7 @@ export class ObjectLiteralCheck implements BaseChecker { for (let arkFile of scene.getFiles()) { const topLevelVarMap: Map = new Map(); - this.collectImportedVar(topLevelVarMap, arkFile); + this.collectImportedVar(topLevelVarMap, arkFile, scene); this.collectTopLevelVar(topLevelVarMap, arkFile, scene); const handleClass = (cls: ArkClass): void => { @@ -106,7 +106,7 @@ export class ObjectLiteralCheck implements BaseChecker { } } - private collectImportedVar(importVarMap: Map, file: ArkFile) { + private collectImportedVar(importVarMap: Map, file: ArkFile, scene: Scene) { file.getImportInfos().forEach(importInfo => { const exportInfo = importInfo.getLazyExportInfo(); if (exportInfo === null) { @@ -120,6 +120,7 @@ export class ObjectLiteralCheck implements BaseChecker { if (!declaringStmt) { return; } + DVFGHelper.buildSingleDVFG(declaringStmt.getCfg().getDeclaringMethod(), scene); importVarMap.set(arkExport.getName(), [declaringStmt]); }); } @@ -382,7 +383,7 @@ export class ObjectLiteralCheck implements BaseChecker { } private getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); diff --git a/ets2panda/linter/homecheck/src/checker/migration/ObservedDecoratorCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/ObservedDecoratorCheck.ts index a6a56e9b4d2ef3d9d95783a0f6d5e03f4fd5004e..8f9c5cdb03a5d1dce03fee6273281375b72ca439 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/ObservedDecoratorCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/ObservedDecoratorCheck.ts @@ -266,7 +266,7 @@ export class ObservedDecoratorCheck implements BaseChecker { canFindAllTargets: boolean = true ): string { if (issueClass === null || !canFindAllTargets) { - return `can not find all classes, please check this field manually`; + return `can not find all classes, please check this field manually (arkui-data-observation)`; } const fieldLine = field.getOriginPosition().getLineNo(); const fieldColumn = field.getOriginPosition().getColNo(); @@ -275,10 +275,10 @@ export class ObservedDecoratorCheck implements BaseChecker { const issueClassSig = issueClass.getDeclaringArkFile().getFileSignature(); let res = `but it's not be annotated by @Observed (arkui-data-observation)`; if (fileSignatureCompare(fieldFileSig, issueClassSig)) { - res = `The class is used by state property in [${fieldLine}, ${fieldColumn}], ` + res; + res = `Class ${issueClass.getName()} is used by state property in [${fieldLine}, ${fieldColumn}], ` + res; } else { const filePath = path.normalize(fieldFileSig.getFileName()); - res = `The class is used by state property in file ${filePath} [${fieldLine}, ${fieldColumn}], ` + res; + res = `Class ${issueClass.getName()} is used by state property in file ${filePath} [${fieldLine}, ${fieldColumn}], ` + res; } return res; } diff --git a/ets2panda/linter/homecheck/src/checker/migration/ThisBindCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/ThisBindCheck.ts index af8657687c1de1e597a6b4a0da9e3d2730f0479e..62a43d0c37bbca88d74a1eea1c329f356770b660 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/ThisBindCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/ThisBindCheck.ts @@ -29,6 +29,7 @@ import { ArkNewExpr, ArkClass, ClassSignature, + ArkReturnStmt, } from 'arkanalyzer'; import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; import { BaseChecker, BaseMetaData } from '../BaseChecker'; @@ -115,7 +116,18 @@ export class ThisBindCheck implements BaseChecker { private useThisInBody(method: ArkMethod): boolean { const thisInstance = (method.getThisInstance() as Local)!; - return thisInstance.getUsedStmts().length > 0; + const usedStmts = thisInstance.getUsedStmts(); + if (method.getName() !== 'constructor') { + return usedStmts.length > 0; + } + // constructor方法一定会有return this语句,此句若为ArkAnalyzer为constructor方法自动生成,则不在检查范围内 + for (const stmt of usedStmts) { + if (stmt instanceof ArkReturnStmt && stmt.getOriginPositionInfo().getLineNo() <= 0) { + continue; + } + return true; + } + return false; } private isSafeUse(v: Value): boolean { @@ -348,7 +360,7 @@ export class ThisBindCheck implements BaseChecker { } private getLineAndColumn(stmt: ArkAssignStmt, operand: Value): WarnInfo { - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); diff --git a/ets2panda/linter/homecheck/src/checker/migration/Utils.ts b/ets2panda/linter/homecheck/src/checker/migration/Utils.ts index 0992bcbe88d2748a8d25a3b7b12b9c8b6492578c..02f114bd0f9d453a33f779834c19a9159a462b57 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/Utils.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/Utils.ts @@ -13,7 +13,18 @@ * limitations under the License. */ -import { ArkAssignStmt, ArkMethod, CallGraph, CallGraphBuilder, Local, LOG_MODULE_TYPE, Logger, Scene, Stmt, Value } from 'arkanalyzer/lib'; +import { + ArkAssignStmt, + ArkMethod, + CallGraph, + CallGraphBuilder, + Local, + LOG_MODULE_TYPE, + Logger, + Scene, + Stmt, + Value, +} from 'arkanalyzer/lib'; import { WarnInfo } from '../../utils/common/Utils'; import { Language } from 'arkanalyzer/lib/core/model/ArkFile'; import { DVFG, DVFGNode } from 'arkanalyzer/lib/VFG/DVFG'; @@ -25,6 +36,10 @@ export const CALL_DEPTH_LIMIT = 2; export class CallGraphHelper { private static cgInstance: CallGraph | null = null; + public static dispose(): void { + this.cgInstance = null; + } + public static getCGInstance(scene: Scene): CallGraph { if (!this.cgInstance) { this.cgInstance = new CallGraph(scene); @@ -36,6 +51,10 @@ export class CallGraphHelper { export class GlobalCallGraphHelper { private static cgInstance: CallGraph | null = null; + public static dispose(): void { + this.cgInstance = null; + } + public static getCGInstance(scene: Scene): CallGraph { if (!this.cgInstance) { this.cgInstance = new CallGraph(scene); @@ -51,6 +70,14 @@ export class DVFGHelper { private static dvfgBuilder: DVFGBuilder; private static built: Set = new Set(); + public static dispose(): void { + // @ts-ignore + this.dvfgInstance = null; + // @ts-ignore + this.dvfgBuilder = null; + this.built.clear(); + } + private static createDVFGInstance(scene: Scene): void { if (!this.dvfgInstance) { this.dvfgInstance = new DVFG(GlobalCallGraphHelper.getCGInstance(scene)); @@ -117,7 +144,7 @@ export function getLanguageStr(language: Language): string { } export function getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { - const arkFile = stmt.getCfg()?.getDeclaringMethod().getDeclaringArkFile(); + const arkFile = stmt.getCfg().getDeclaringMethod().getDeclaringArkFile(); const originPosition = stmt.getOperandOriginalPosition(operand); if (arkFile && originPosition) { const originPath = arkFile.getFilePath(); @@ -126,7 +153,7 @@ export function getLineAndColumn(stmt: Stmt, operand: Value): WarnInfo { const endCol = startCol; return { line, startCol, endCol, filePath: originPath }; } else { - logger.debug('ArkFile is null.'); + logger.debug('ArkFile or operand position is null.'); } return { line: -1, startCol: -1, endCol: -1, filePath: '' }; } diff --git a/ets2panda/linter/homecheck/src/tools/migrationTool/MigrationTool.ts b/ets2panda/linter/homecheck/src/tools/migrationTool/MigrationTool.ts index 5c3f6478eda979502d63bbb9e1cd817ead03cd0e..7be52a159ab6906519aff74c6c3634d503716c0e 100644 --- a/ets2panda/linter/homecheck/src/tools/migrationTool/MigrationTool.ts +++ b/ets2panda/linter/homecheck/src/tools/migrationTool/MigrationTool.ts @@ -21,7 +21,8 @@ import { CheckerStorage } from '../../utils/common/CheckerStorage'; import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; import { FileUtils } from '../../utils/common/FileUtils'; import { DefaultMessage } from '../../model/Message'; -import { FileIssues } from "../../model/Defects"; +import { FileIssues } from '../../model/Defects'; +import { CallGraphHelper, DVFGHelper, GlobalCallGraphHelper } from '../../checker/migration/Utils'; const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'MigrationTool'); @@ -68,7 +69,16 @@ export class MigrationTool { await this.checkEntry.runAll(); let result = this.checkEntry.sortIssues(); + this.dispose(); logger.info(`MigrationTool run end`); return result; } + + private dispose(): void { + CallGraphHelper.dispose(); + GlobalCallGraphHelper.dispose(); + DVFGHelper.dispose(); + CheckerStorage.dispose(); + this.checkEntry.scene.dispose(); + } } \ No newline at end of file diff --git a/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts b/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts index b022e5bd1227339a2646678c688f74b18f39cb1e..9e43517c0f45412bcb8917da2dbedb2011e8908b 100644 --- a/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts +++ b/ets2panda/linter/homecheck/src/utils/common/CheckerIndex.ts @@ -27,6 +27,8 @@ import { InteropObjectLiteralCheck } from '../../checker/migration/InteropDynami import { InteropAssignCheck } from '../../checker/migration/InteropAssignCheck'; import { InteropJSModifyPropertyCheck } from '../../checker/migration/InteropJSModifyPropertyCheck'; import { NoTSLikeAsCheck } from '../../checker/migration/NoTSLikeAsCheck'; +import { InteropS2DObjectLiteralCheck } from '../../checker/migration/InteropS2DObjectLiteralsCheck'; +import { InteropDeprecatedBuiltInAPICheck } from '../../checker/migration/InteropDeprecatedBuiltInAPICheck'; const logger = Logger.getLogger(LOG_MODULE_TYPE.HOMECHECK, 'CheckerIndex'); @@ -38,6 +40,7 @@ export const fileRules = { '@migration/arkui-custombuilder-passing': CustomBuilderCheck, '@migration/no-method-overriding-field-check': NoMethodOverridingFieldCheck, '@migration/interop-boxed-type-check': InteropBoxedTypeCheck, + '@migration/arkts-interop-s2d-object-literal': InteropS2DObjectLiteralCheck, }; export const projectRules = { @@ -47,6 +50,7 @@ export const projectRules = { '@migration/interop-js-modify-property': InteropJSModifyPropertyCheck, '@migration/interop-dynamic-object-literals': InteropObjectLiteralCheck, '@migration/arkts-no-ts-like-as': NoTSLikeAsCheck, + '@migration/arkts-interop-s2d-dynamic-call-builtin-api-not-in-static': InteropDeprecatedBuiltInAPICheck, }; // 新增文件级的checker,需要在此处注册 diff --git a/ets2panda/linter/homecheck/src/utils/common/CheckerStorage.ts b/ets2panda/linter/homecheck/src/utils/common/CheckerStorage.ts index f3bedd5017d59910d6579916b5fb00d2a2f1a9c3..922b716e95b63524327ca53c62cd89ff72d5b855 100644 --- a/ets2panda/linter/homecheck/src/utils/common/CheckerStorage.ts +++ b/ets2panda/linter/homecheck/src/utils/common/CheckerStorage.ts @@ -21,6 +21,11 @@ export class CheckerStorage { private apiVersion: number = 16; private product: string = ''; + public static dispose(): void { + // @ts-ignore + this.instance = null; + } + /** * 获取 CheckerStorage 的单例实例 * @returns {CheckerStorage} CheckerStorage 的单例实例 diff --git a/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts b/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts index 48b06a414dc94e9e5474890f8a89dd32be5116fd..f17425f284605ab9f4cd9738a2ec9fc9c72121ba 100644 --- a/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts +++ b/ets2panda/linter/homecheck/src/utils/common/FileUtils.ts @@ -232,7 +232,7 @@ export class FileUtils { } private static shouldSkipFile(fileName: string): boolean { - return ['oh_modules', 'node_modules', 'hvigorfile.ts', 'ohosTest'].includes(fileName); + return ['oh_modules', 'node_modules', 'hvigorfile.ts', 'hvigorfile.js', 'hvigor-wrapper.js', 'ohosTest'].includes(fileName); } private static shouldAddFile(filePath: string, exts: string[]): boolean { @@ -310,4 +310,4 @@ export class FileUtils { export enum WriteFileMode { OVERWRITE, APPEND -} \ No newline at end of file +} diff --git a/ets2panda/linter/package.json b/ets2panda/linter/package.json index 9c02abca4546da39b55045be4245ee1f063e3d13..7b374c99446f72623c7be16bb317357464add5a4 100644 --- a/ets2panda/linter/package.json +++ b/ets2panda/linter/package.json @@ -17,7 +17,7 @@ "postcompile": "node scripts/testRunner/post-compile.mjs", "build": "npm run clean && npm run compile && npm run webpack && npm run pack:linter", "install-ohos-typescript": "node scripts/install-ohos-typescript-and-homecheck.mjs", - "pack:linter": "rimraf bundle && mkdir bundle && npm pack --pack-destination bundle", + "pack:linter": "rimraf bundle && mkdir bundle && npm pack && mv panda-tslinter-*.tgz bundle", "pretest": " npm run fix", "test": "npm run test_all && npm run test_ts_import_ets", "test_all": "npm run testrunner -- -d test/main,test/rules,test/regression,test/extended_features,test/migration,test/ohmurl,test/interop,test/sdkwhite,test/concurrent,test/builtin", diff --git a/ets2panda/linter/src/cli/CommandLineParser.ts b/ets2panda/linter/src/cli/CommandLineParser.ts index d20a18c218867a72fc21cb608ce62aa073e5fd2a..9849eedf17ddf941595d7bb0021890af6a008f74 100644 --- a/ets2panda/linter/src/cli/CommandLineParser.ts +++ b/ets2panda/linter/src/cli/CommandLineParser.ts @@ -152,6 +152,9 @@ function formArkts2Options(cmdOptions: CommandLineOptions, commanderOpts: Option if (commanderOpts.verbose) { cmdOptions.verbose = true; } + if (commanderOpts.enableInterop) { + cmdOptions.scanWholeProjectInHomecheck = true; + } } function formCommandLineOptions(parsedCmd: ParsedCommand): CommandLineOptions { @@ -226,12 +229,10 @@ function createCommand(): Command { option('--migration-max-pass ', 'Maximum number of migration passes'). option('--migration-report', 'Generate migration report'). option('--check-ts-and-js', 'check ts and js files'). - option( - '--only-arkts2-syntax-rules', - 'only syntax rules, excluding rules such as SDK, Arkui, Interop, Concurrent, etc' - ). + option('--only-arkts2-syntax-rules', 'only syntax rules'). option('-o, --output-file-path ', 'path to store all log and result files'). option('--verbose', 'set log level to see debug messages'). + option('--enable-interop', 'scan whole project to report 1.1 import 1.2'). addOption(new Option('--warnings-as-errors', 'treat warnings as errors').hideHelp(true)). addOption(new Option('--no-check-ts-as-source', 'check TS files as third-party libary').hideHelp(true)). addOption(new Option('--no-use-rt-logic', 'run linter with SDK logic').hideHelp(true)). diff --git a/ets2panda/linter/src/cli/LinterCLI.ts b/ets2panda/linter/src/cli/LinterCLI.ts index 45bd9fddcd788362a353d59c33e646bac8156c4e..5af05d0e31d4fb5c119c8b7e7abed8baa51458fb 100644 --- a/ets2panda/linter/src/cli/LinterCLI.ts +++ b/ets2panda/linter/src/cli/LinterCLI.ts @@ -58,9 +58,10 @@ async function runIdeInteractiveMode(cmdOptions: CommandLineOptions): Promise { + return problem.rule.includes('s2d'); + }); + if (filteredProblems.length > 0) { + mergedProblems.set(file, filteredProblems); + } else { + mergedProblems.delete(file); + } + } + } } async function generateReportFile(reportData, reportPath?: string): Promise { diff --git a/ets2panda/linter/src/lib/BaseTypeScriptLinter.ts b/ets2panda/linter/src/lib/BaseTypeScriptLinter.ts index 82bf349ba604f6c291540d90ddbdf5d52cd3fea3..e1e433013c991aa8d5ee31af47b3f558ad34519e 100644 --- a/ets2panda/linter/src/lib/BaseTypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/BaseTypeScriptLinter.ts @@ -69,7 +69,12 @@ export abstract class BaseTypeScriptLinter { }); } - protected incrementCounters(node: ts.Node | ts.CommentRange, faultId: number, autofix?: Autofix[]): void { + protected incrementCounters( + node: ts.Node | ts.CommentRange, + faultId: number, + autofix?: Autofix[], + errorMsg?: string + ): void { const [startOffset, endOffset] = TsUtils.getHighlightRange(node, faultId); const startPos = this.sourceFile.getLineAndCharacterOfPosition(startOffset); const endPos = this.sourceFile.getLineAndCharacterOfPosition(endOffset); @@ -78,7 +83,7 @@ export abstract class BaseTypeScriptLinter { const faultType = TypeScriptLinterConfig.tsSyntaxKindNames[node.kind]; const cookBookMsgNum = faultsAttrs[faultId] ? faultsAttrs[faultId].cookBookRef : 0; - const cookBookTg = cookBookTag[cookBookMsgNum]; + const cookBookTg = errorMsg ? errorMsg : cookBookTag[cookBookMsgNum]; const severity = faultsAttrs[faultId]?.severity ?? ProblemSeverity.ERROR; const isMsgNumValid = cookBookMsgNum > 0; autofix = autofix ? BaseTypeScriptLinter.addLineColumnInfoInAutofix(autofix, startPos, endPos) : autofix; diff --git a/ets2panda/linter/src/lib/CommandLineOptions.ts b/ets2panda/linter/src/lib/CommandLineOptions.ts index cbcc81f622d95eefffeee129a70e56b593cf8904..1bdde46faeaa7c3be16eb3717c3f666ed2658765 100644 --- a/ets2panda/linter/src/lib/CommandLineOptions.ts +++ b/ets2panda/linter/src/lib/CommandLineOptions.ts @@ -33,4 +33,5 @@ export interface CommandLineOptions { disableStrictDiagnostics?: boolean; outputFilePath?: string; verbose?: boolean; + scanWholeProjectInHomecheck?: boolean; } diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 4fe5be46599a545efdd9b46e0f139b7742585557..17c0d8899bd90376a4622929ddf11a9814eef842 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -236,7 +236,7 @@ cookBookTag[198] = 'Class TS overloading is not supported(arkts-no-ts-overload)' cookBookTag[199] = 'Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)'; cookBookTag[202] = 'Literal types are restricted(arkts-limited-literal-types)'; cookBookTag[203] = 'exponent opartions "**" and "**=" are disabled (arkts-no-exponent-op)'; -cookBookTag[206] = '"debugger" is not supported (arkts-no-debugger-stmt)'; +cookBookTag[206] = '"debugger" is not supported (arkts-no-debugger)'; cookBookTag[207] = 'Special arguments object inside functions are not supported (arkts-no-arguments-obj)'; cookBookTag[208] = 'Tagged templates are not supported (arkts-no-tagged-templates)'; cookBookTag[209] = 'The index expression must be of a numeric type (arkts-array-index-expr-type)'; @@ -245,7 +245,7 @@ cookBookTag[210] = cookBookTag[211] = 'No two case constant expressions have identical values.(arkts-case-expr)'; cookBookTag[212] = 'The index expression must be zero or positive value.(arkts-array-index-negative)'; cookBookTag[213] = 'Class cannot have static codeblocks. (arkts-class-lazy-import)'; -cookBookTag[214] = 'The Class object does not have a constructor. (arkts-no-arkts-constructor)'; +cookBookTag[214] = 'Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)'; cookBookTag[215] = 'Array bound not checked. (arkts-runtime-array-check)'; cookBookTag[222] = 'Import for side-effect only is prohibited.(arkts-no-side-effect-import)'; cookBookTag[232] = 'Lazy import is not supported(arkts-no-lazy-import)'; @@ -265,28 +265,29 @@ cookBookTag[256] = '"@Styles" decorator is not supported (arkui-no-styles-decora cookBookTag[257] = '"@AnimatableExtend" decorator should be transformed to use receiver (arkui-animatableextend-use-receiver)'; cookBookTag[258] = 'Data observation needs to add "@Observed" (arkui-data-observation)'; -cookBookTag[259] = 'ArkUI interface should be imported before using (arkui-modular-interface)'; +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[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)'; -cookBookTag[264] = 'Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)'; cookBookTag[265] = 'Direct inheritance of interop JS classes is not supported (arkts-interop-js2s-inherit-js-class)'; cookBookTag[266] = 'Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)'; cookBookTag[267] = 'Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)'; cookBookTag[268] = 'Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)'; cookBookTag[269] = 'Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)'; -cookBookTag[270] = 'Trying to catch JS errors is not permitted (arkts-interop-js2s-js-exception)'; +cookBookTag[270] = 'ArkTS1.2 cannot catch a non Error instance thrown from JS code (arkts-interop-js2s-js-exception)'; cookBookTag[274] = 'The subclass constructor must call the parent class\'s parametered constructor (arkts-subclass-must-call-super-constructor-with-args)'; cookBookTag[275] = - 'Custom components with custom layout capability need to add the "@Layoutable" decorator (arkui-custom-layout-need-add-decorator)'; + 'Custom components with custom layout capability need to add the "@CustomLayout" decorator (arkui-custom-layout-need-add-decorator)'; cookBookTag[281] = '"@Prop" decorator is not supported (arkui-no-prop-decorator)'; cookBookTag[282] = '"@StorageProp" decorator is not supported (arkui-no-storageprop-decorator)'; cookBookTag[283] = '"@LocalStorageProp" decorator is not supported (arkui-no-localstorageprop-decorator)'; cookBookTag[284] = '"prop" function is not supported (arkui-no-prop-function)'; cookBookTag[285] = '"setAndProp" function is not supported (arkui-no-setandprop-function)'; +cookBookTag[286] = + 'Parameters decorated with "@Prop" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)'; cookBookTag[300] = 'The function type should be explicit (arkts-no-ts-like-function-call)'; cookBookTag[301] = 'Importing from "oh module" requires specifying full path (arkts-ohmurl-full-path)'; cookBookTag[302] = @@ -322,7 +323,7 @@ cookBookTag[327] = 'Object literal not compatible with target union type. (arkts-interop-d2s-object-literal-no-ambiguity)'; cookBookTag[328] = 'Object literal cannot be directly assigned to class with a constructor. (arkts-interop-d2s-object-literal-no-args-constructor)'; -cookBookTag[329] = 'Enum cannot get member name by member value (arkts-unsupport-prop-name-from-value)'; +cookBookTag[329] = 'Enum cannot get member name by member value (arkts-enum-no-props-by-index)'; cookBookTag[330] = 'Importing directly from "JS" module is not supported (arkts-interop-js2s-import-js)'; cookBookTag[331] = 'ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)'; cookBookTag[332] = 'Properties of interop objects can\'t be accessed directly (arkts-interop-js2s-access-js-prop)'; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index e198eb4e83e03202f44a2b1107cfeae61ff7c500..07f558781204611ba359931c5a7eed7698a7e24f 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -186,10 +186,9 @@ faultsAttrs[FaultID.UIInterfaceImport] = new FaultAttributes(259); faultsAttrs[FaultID.EntryAnnotation] = new FaultAttributes(260); faultsAttrs[FaultID.MakeObservedIsNotSupported] = new FaultAttributes(262); faultsAttrs[FaultID.ProvideAnnotation] = new FaultAttributes(263); -faultsAttrs[FaultID.InteropJsObjectUsage] = new FaultAttributes(264); faultsAttrs[FaultID.InteropJsObjectInheritance] = new FaultAttributes(265); faultsAttrs[FaultID.InteropJsObjectTraverseJsInstance] = new FaultAttributes(266); -faultsAttrs[FaultID.InteropJsObjectCallStaticFunc] = new FaultAttributes(267); +faultsAttrs[FaultID.InteropJsObjectCallStaticFunc] = new FaultAttributes(267, ProblemSeverity.WARNING); faultsAttrs[FaultID.InteropJsObjectConditionJudgment] = new FaultAttributes(268); faultsAttrs[FaultID.InteropJsObjectExpandStaticInstance] = new FaultAttributes(269); faultsAttrs[FaultID.InteropJSFunctionInvoke] = new FaultAttributes(270); @@ -200,6 +199,7 @@ faultsAttrs[FaultID.StoragePropDecoratorNotSupported] = new FaultAttributes(282) faultsAttrs[FaultID.LocalStoragePropDecoratorNotSupported] = new FaultAttributes(283); faultsAttrs[FaultID.PropFunctionNotSupported] = new FaultAttributes(284); faultsAttrs[FaultID.SetAndPropFunctionNotSupported] = new FaultAttributes(285); +faultsAttrs[FaultID.PropNeedCallMethodForDeepCopy] = new FaultAttributes(286); faultsAttrs[FaultID.ExplicitFunctionType] = new FaultAttributes(300); faultsAttrs[FaultID.OhmUrlFullPath] = new FaultAttributes(301); faultsAttrs[FaultID.InteropCallObjectParam] = new FaultAttributes(302); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 1dd89ea9683eb89562c10a9966f010372cb8b9b8..49646a196571a5d6652e4004e62f4ed2c9ae207e 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -190,7 +190,6 @@ 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.ProvideAnnotation] = '"@Provide" decorator parameter'; -faultDesc[FaultID.InteropJsObjectUsage] = 'Interop JS object usage'; faultDesc[FaultID.InteropJsObjectInheritance] = 'Interop JS class inheritance'; faultDesc[FaultID.InteropJsObjectTraverseJsInstance] = 'Interop JS object traverse usage'; faultDesc[FaultID.InteropJsObjectCallStaticFunc] = 'Interop JS function usage'; @@ -252,3 +251,4 @@ faultDesc[FaultID.StoragePropDecoratorNotSupported] = '"@StorageProp" decorator faultDesc[FaultID.LocalStoragePropDecoratorNotSupported] = '"@LocalStorageProp" decorator is not supported'; faultDesc[FaultID.PropFunctionNotSupported] = '"prop" function is not supported'; faultDesc[FaultID.SetAndPropFunctionNotSupported] = '"setAndProp" function is not supported'; +faultDesc[FaultID.PropNeedCallMethodForDeepCopy] = 'Deep copy needs to call the specific method'; diff --git a/ets2panda/linter/src/lib/HomeCheck.ts b/ets2panda/linter/src/lib/HomeCheck.ts index abf128b57f1fe8b3dbe44e45c24c46868ad456cf..6ad5e01ad9d6fa2a490d11c40dbf30f46871eaf6 100644 --- a/ets2panda/linter/src/lib/HomeCheck.ts +++ b/ets2panda/linter/src/lib/HomeCheck.ts @@ -18,6 +18,7 @@ import type { FileIssues, RuleFix } from 'homecheck'; import type { CommandLineOptions } from './CommandLineOptions'; import type { ProblemInfo } from './ProblemInfo'; import { FaultID } from './Problems'; +import { shouldProcessFile } from './LinterRunner'; interface RuleConfigInfo { ruleSet: string[]; @@ -39,8 +40,18 @@ export function getHomeCheckConfigInfo(cmdOptions: CommandLineOptions): { ruleConfigInfo: RuleConfigInfo; projectConfigInfo: ProjectConfigInfo; } { + let inputFiles = cmdOptions.inputFiles; + let fliesTocheck: string[] = inputFiles; + if (cmdOptions.scanWholeProjectInHomecheck === true) { + fliesTocheck = []; + } + inputFiles = inputFiles.filter((input) => { + return shouldProcessFile(cmdOptions, input); + }); const languageTags = new Map(); - const inputFiles = cmdOptions.inputFiles; + inputFiles.forEach((file) => { + languageTags.set(path.normalize(file), 2); + }); const ruleConfigInfo = { ruleSet: ['plugin:@migration/all'], files: ['**/*.ets', '**/*.ts', '**/*.js'] @@ -54,7 +65,7 @@ export function getHomeCheckConfigInfo(cmdOptions: CommandLineOptions): { hmsSdkPath: cmdOptions.sdkExternalApiPath ? cmdOptions.sdkExternalApiPath[0] : '', reportDir: './', languageTags: languageTags, - fileOrFolderToCheck: inputFiles, + fileOrFolderToCheck: fliesTocheck, logLevel: cmdOptions.verbose ? 'DEBUG' : 'INFO', arkAnalyzerLogLevel: cmdOptions.verbose ? 'DEBUG' : 'ERROR' }; diff --git a/ets2panda/linter/src/lib/LinterOptions.ts b/ets2panda/linter/src/lib/LinterOptions.ts index f6124ac4ab079343ddac9223baed63f1b58d53ca..72613a4cd1648f8febcc6e49c1263e7d21883b29 100644 --- a/ets2panda/linter/src/lib/LinterOptions.ts +++ b/ets2panda/linter/src/lib/LinterOptions.ts @@ -45,4 +45,5 @@ export interface LinterOptions { migrationReport?: boolean; wholeProjectPath?: string; checkTsAndJs?: boolean; + inputFiles?: string[]; } diff --git a/ets2panda/linter/src/lib/LinterRunner.ts b/ets2panda/linter/src/lib/LinterRunner.ts index 04fc4174f4645cbc2b78ca289d286cebc7dfa497..453731f7bcaf14ae41e51d199c22b75f73572acb 100644 --- a/ets2panda/linter/src/lib/LinterRunner.ts +++ b/ets2panda/linter/src/lib/LinterRunner.ts @@ -31,6 +31,7 @@ import { ARKTS_IGNORE_DIRS_OH_MODULES, ARKTS_IGNORE_FILES } from './utils/consts/ArktsIgnorePaths'; +import { USE_STATIC } from './utils/consts/InteropAPI'; import { EXTNAME_TS, EXTNAME_JS } from './utils/consts/ExtensionName'; import { mergeArrayMaps } from './utils/functions/MergeArrayMaps'; import { clearPathHelperCache, pathContainsDirectory } from './utils/functions/PathHelper'; @@ -42,7 +43,9 @@ import { ProjectStatistics } from './statistics/ProjectStatistics'; import type { BaseTypeScriptLinter } from './BaseTypeScriptLinter'; function prepareInputFilesList(cmdOptions: CommandLineOptions): string[] { - let inputFiles = cmdOptions.inputFiles; + let inputFiles = cmdOptions.inputFiles.map((x) => { + return path.normalize(x); + }); if (!cmdOptions.parsedConfigFile) { return inputFiles; } @@ -93,6 +96,7 @@ function lintImpl(config: LinterConfig): LintRunResult { inputFiles = inputFiles.filter((input) => { return shouldProcessFile(options, input); }); + options.inputFiles = inputFiles; const srcFiles: ts.SourceFile[] = []; for (const inputFile of inputFiles) { const srcFile = tsProgram.getSourceFile(inputFile); @@ -185,6 +189,18 @@ function migrate( return lintResult; } +function hasUseStaticDirective(srcFile: ts.SourceFile): boolean { + if (!srcFile?.statements.length) { + return false; + } + const statements = srcFile.statements; + return ( + ts.isExpressionStatement(statements[0]) && + ts.isStringLiteral(statements[0].expression) && + statements[0].expression.getText() === USE_STATIC + ); +} + function fix( linterConfig: LinterConfig, lintResult: LintRunResult, @@ -204,17 +220,22 @@ function fix( } } mergedProblems.forEach((problemInfos, fileName) => { - // If nothing to fix, skip file - if (!qEd.QuasiEditor.hasAnyAutofixes(problemInfos)) { - return; - } - const srcFile = program.getSourceFile(fileName); if (!srcFile) { - Logger.error(`Failed to retrieve source file: ${fileName}`); + if (!linterConfig.cmdOptions.homecheck) { + Logger.error(`Failed to retrieve source file: ${fileName}`); + } + return; + } + const needToAddUseStatic = + linterConfig.cmdOptions.linterOptions.arkts2 && + linterConfig.cmdOptions.inputFiles.includes(fileName) && + !hasUseStaticDirective(srcFile) && + linterConfig.cmdOptions.linterOptions.ideInteractive; + // If nothing to fix or don't need to add 'use static', then skip file + if (!qEd.QuasiEditor.hasAnyAutofixes(problemInfos) && !needToAddUseStatic) { return; } - const qe: qEd.QuasiEditor = new qEd.QuasiEditor( fileName, srcFile.text, @@ -222,7 +243,7 @@ function fix( undefined, linterConfig.cmdOptions.outputFilePath ); - updatedSourceTexts.set(fileName, qe.fix(problemInfos)); + updatedSourceTexts.set(fileName, qe.fix(problemInfos, needToAddUseStatic)); appliedFix = true; }); @@ -242,7 +263,7 @@ function getMigrationCreateProgramCallback(updatedSourceTexts: Map; static literalAsPropertyNameTypeSet: Set; private localApiListItem: ApiListItem | undefined = undefined; + static constructorFuncsSet: Set; static initGlobals(): void { TypeScriptLinter.sharedModulesCache = new Map(); @@ -249,6 +250,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private static addSdkConstructorFuncsSetData(item: ApiListItem): void { + if (item.api_info.problem === SdkProblem.ConstructorFuncs) { + TypeScriptLinter.constructorFuncsSet.add(item); + } + } + private static addGlobalApiInfosCollocetionData(item: ApiListItem): void { const problemType = item.api_info.problem; const isGlobal = item.is_global; @@ -264,6 +271,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private static initSdkWhitelist(): void { TypeScriptLinter.indexedTypeSet = new Set(); TypeScriptLinter.literalAsPropertyNameTypeSet = new Set(); + TypeScriptLinter.constructorFuncsSet = new Set(); const list: ApiList = new ApiList(apiWhiteList); if (list?.api_list?.length > 0) { for (const item of list.api_list) { @@ -275,6 +283,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { }); TypeScriptLinter.addSdkIndexedTypeSetData(item); TypeScriptLinter.addSdkliteralAsPropertyNameTypeSetData(item); + TypeScriptLinter.addSdkConstructorFuncsSetData(item); TypeScriptLinter.addGlobalApiInfosCollocetionData(item); } } @@ -324,7 +333,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { [ts.SyntaxKind.ForStatement, this.handleForStatement], [ts.SyntaxKind.ForInStatement, this.handleForInStatement], [ts.SyntaxKind.ForOfStatement, this.handleForOfStatement], - [ts.SyntaxKind.IfStatement, this.handleIfStatement], [ts.SyntaxKind.ImportDeclaration, this.handleImportDeclaration], [ts.SyntaxKind.PropertyAccessExpression, this.handlePropertyAccessExpression], [ts.SyntaxKind.PropertyDeclaration, this.handlePropertyDeclaration], @@ -399,7 +407,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.autofixer = new Autofixer(this.tsTypeChecker, this.tsUtils, this.sourceFile, this.options.cancellationToken); } - this.useStatic = TsUtils.isArkts12File(this.sourceFile); + this.useStatic = this.tsUtils.isArkts12File(this.sourceFile); this.fileExportDeclCaches = undefined; this.extractImportedNames(this.sourceFile); this.visitSourceFile(this.sourceFile); @@ -610,9 +618,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } for (const prop of invalidProps) { - if (ts.isShorthandPropertyAssignment(prop) && !TsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(prop))) { - continue; - } const autofix = ts.isShorthandPropertyAssignment(prop) ? this.autofixer?.fixShorthandPropertyAssignment(prop) : objLiteralAutofix; @@ -643,6 +648,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { * e.g. there is no element which is untyped object literals */ const arrayLitElements = arrayLitNode.elements; + if (this.options.arkts2 && !arrayLitType && arrayLitElements.length === 0) { + this.incrementCounters(node, FaultID.NosparseArray); + } for (const element of arrayLitElements) { const elementContextType = this.tsTypeChecker.getContextualType(element); if (ts.isObjectLiteralExpression(element)) { @@ -683,10 +691,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleDeclarationDestructuring(tsParam); this.handleDeclarationInferredType(tsParam); this.handleInvalidIdentifier(tsParam); - this.handleSdkDuplicateDeclName(tsParam); + this.handleSdkGlobalApi(tsParam); const typeNode = tsParam.type; - if (this.options.arkts2 && typeNode && typeNode.kind === ts.SyntaxKind.VoidKeyword) { - this.incrementCounters(typeNode, FaultID.LimitedVoidType); + if (this.options.arkts2 && typeNode && TsUtils.typeContainsVoid(typeNode)) { + const autofix = this.autofixer?.fixLimitedVoidType(tsParam); + this.incrementCounters(typeNode, FaultID.LimitedVoidType, autofix); } this.handlePropertyDescriptorInScenarios(tsParam); } @@ -913,78 +922,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const tsForStmt = node as ts.ForStatement; const tsForInit = tsForStmt.initializer; if (tsForInit) { - this.checkStaticArrayControl(tsForStmt); this.checkForLoopDestructuring(tsForInit); } } - private checkStaticArrayControl(tsForStmt: ts.ForStatement): void { - if (!this.options.arkts2 || !this.useStatic) { - return; - } - - if (!ts.isBlock(tsForStmt.statement)) { - return; - } - - const loopBody = tsForStmt.statement; - const arrayAccessInfo = this.checkBodyHasArrayAccess(loopBody); - const loopCondition = tsForStmt.condition; - - if (!arrayAccessInfo) { - return; - } - if (!loopCondition) { - this.incrementCounters(arrayAccessInfo.arrayIdent.parent, FaultID.RuntimeArrayCheck); - return; - } - const arraySymbol = this.tsUtils.trueSymbolAtLocation(arrayAccessInfo.arrayIdent); - if (!arraySymbol) { - return; - } - - const arrayCheckedAgainst = this.checkConditionForArrayAccess(loopCondition, arraySymbol); - if (!arrayCheckedAgainst) { - this.incrementCounters(arrayAccessInfo.arrayIdent.parent, FaultID.RuntimeArrayCheck); - return; - } - - this.checkIfAccessAndCheckVariablesMatch(arrayAccessInfo, arrayCheckedAgainst); - } - - private checkIfAccessAndCheckVariablesMatch(accessInfo: ArrayAccess, checkedAgainst: CheckedIdentifier): void { - const { arrayIdent, accessingIdentifier } = accessInfo; - - if (accessingIdentifier === NUMBER_LITERAL) { - if (checkedAgainst === NUMBER_LITERAL) { - return; - } - this.incrementCounters(arrayIdent.parent, FaultID.RuntimeArrayCheck); - return; - } - - if (checkedAgainst === NUMBER_LITERAL) { - this.incrementCounters(arrayIdent.parent, FaultID.RuntimeArrayCheck); - return; - } - - const checkedAgainstSym = this.tsUtils.trueSymbolAtLocation(checkedAgainst); - if (!checkedAgainstSym) { - return; - } - - const accessingIdentSym = this.tsUtils.trueSymbolAtLocation(accessingIdentifier); - - if (checkedAgainstSym !== accessingIdentSym) { - this.incrementCounters(arrayIdent.parent, FaultID.RuntimeArrayCheck); - return; - } - - if (this.isChangedAfterCheck(arrayIdent.getSourceFile(), checkedAgainstSym)) { - this.incrementCounters(arrayIdent.parent, FaultID.RuntimeArrayCheck); - } - } - private checkConditionForArrayAccess(condition: ts.Expression, arraySymbol: ts.Symbol): UncheckedIdentifier { if (!ts.isBinaryExpression(condition)) { return undefined; @@ -1048,115 +989,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return arrayAccessResult; } - private checkArrayUsageWithoutBound(accessExpr: ts.ElementAccessExpression): void { - if (!this.options.arkts2 || !this.useStatic) { - return; - } - - const arrayAccessInfo = this.isElementAccessOfArray(accessExpr); - if (!arrayAccessInfo) { - return; - } - - const { arrayIdent } = arrayAccessInfo; - const arraySym = this.tsUtils.trueSymbolAtLocation(arrayIdent); - if (!arraySym) { - return; - } - const sourceFile = arrayIdent.getSourceFile(); - let boundChecked = true; - - for (const statement of sourceFile.statements) { - const checkResult = this.checkStatementForArrayAccess(statement, arrayAccessInfo, arraySym); - if (checkResult === CheckResult.SKIP) { - boundChecked = false; - continue; - } - - if (checkResult === CheckResult.HAS_ARRAY_ACCES) { - continue; - } - - if (checkResult === CheckResult.CHECKED) { - boundChecked = true; - break; - } - } - - if (!boundChecked) { - this.incrementCounters(arrayIdent.parent, FaultID.RuntimeArrayCheck); - } - } - - private checkStatementForArrayAccess( - statement: ts.Statement, - accessInfo: ArrayAccess, - arraySym: ts.Symbol - ): CheckResult { - if (ts.isForStatement(statement)) { - return this.isThisArrayAccess(statement.statement as ts.Block, accessInfo.arrayIdent); - } - - if (!ts.isIfStatement(statement)) { - return CheckResult.SKIP; - } - - const thisArrayAccess = this.isThisArrayAccess(statement.thenStatement as ts.Block, accessInfo.arrayIdent); - if (thisArrayAccess !== CheckResult.SKIP) { - return thisArrayAccess; - } - - const checkedAgainst = this.checkConditionForArrayAccess(statement.expression, arraySym); - if (!checkedAgainst) { - return CheckResult.SKIP; - } - - this.checkIfAccessAndCheckVariablesMatch(accessInfo, checkedAgainst); - return CheckResult.CHECKED; - } - - private isThisArrayAccess(block: ts.Block, arrayIdent: ts.Identifier): CheckResult { - const info = this.checkBodyHasArrayAccess(block); - if (!info) { - return CheckResult.SKIP; - } - - if (info.arrayIdent === arrayIdent) { - return CheckResult.CHECKED; - } - - return CheckResult.HAS_ARRAY_ACCES; - } - - private isChangedAfterCheck(sourceFile: ts.SourceFile, sym: ts.Symbol): boolean { - for (const statement of sourceFile.statements) { - if (!ts.isExpressionStatement(statement)) { - continue; - } - if (!ts.isBinaryExpression(statement.expression)) { - continue; - } - if (!ts.isIdentifier(statement.expression.left)) { - continue; - } - if (statement.expression.operatorToken.kind !== ts.SyntaxKind.EqualsToken) { - continue; - } - - const leftSym = this.tsUtils.trueSymbolAtLocation(statement.expression.left); - if (!leftSym) { - continue; - } - - if (leftSym === sym) { - return true; - } - continue; - } - - return false; - } - private handleForInStatement(node: ts.Node): void { const tsForInStmt = node as ts.ForInStatement; const tsForInInit = tsForInStmt.initializer; @@ -1168,42 +1000,21 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const tsForOfStmt = node as ts.ForOfStatement; const tsForOfInit = tsForOfStmt.initializer; this.checkForLoopDestructuring(tsForOfInit); + this.handleForOfJsArray(tsForOfStmt); } - private handleIfStatement(ifStatement: ts.IfStatement): void { - if (this.options.arkts2 && this.useStatic) { - this.checkIfStatementForArrayUsage(ifStatement); - } - } - - private checkIfStatementForArrayUsage(ifStatement: ts.IfStatement): void { - if (!ts.isBlock(ifStatement.thenStatement)) { - return; - } - - const accessInfo = this.checkBodyHasArrayAccess(ifStatement.thenStatement); - if (!accessInfo) { - return; - } - const { arrayIdent } = accessInfo; - - const arraySymbol = this.tsUtils.trueSymbolAtLocation(arrayIdent); - if (!arraySymbol) { + private updateDataSdkJsonInfo(importDeclNode: ts.ImportDeclaration, importClause: ts.ImportClause): void { + const sdkInfo = TypeScriptLinter.pathMap.get(importDeclNode.moduleSpecifier.getText()); + if (!sdkInfo) { return; } - - const checkedAgainst = this.checkConditionForArrayAccess(ifStatement.expression, arraySymbol); - if (!checkedAgainst) { - this.incrementCounters(arrayIdent, FaultID.RuntimeArrayCheck); - return; + if (importClause.name) { + const importClauseName = importClause.name.text; + sdkInfo.forEach((info) => { + TypeScriptLinter.addOrUpdateData(this.interfaceMap, importClauseName, info); + }); } - - this.checkIfAccessAndCheckVariablesMatch(accessInfo, checkedAgainst); - } - - private updateDataSdkJsonInfo(importDeclNode: ts.ImportDeclaration, importClause: ts.ImportClause): void { - const sdkInfo = TypeScriptLinter.pathMap.get(importDeclNode.moduleSpecifier.getText()); - if (sdkInfo && importClause.namedBindings) { + if (importClause.namedBindings) { const namedImports = importClause.namedBindings as ts.NamedImports; if (!namedImports.elements) { return; @@ -1364,11 +1175,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleLimitedVoidTypeFromSdkOnPropertyAccessExpression(node as ts.PropertyAccessExpression); this.checkDepricatedIsConcurrent(node as ts.PropertyAccessExpression); this.propertyAccessExpressionForBuiltin(node as ts.PropertyAccessExpression); - + this.checkConstrutorAccess(node as ts.PropertyAccessExpression); + this.handleTaskPoolDeprecatedUsages(node as ts.PropertyAccessExpression); + this.handleNoTuplesArraysForPropertyAccessExpression(node as ts.PropertyAccessExpression); if (ts.isCallExpression(node.parent) && node === node.parent.expression) { return; } - const propertyAccessNode = node as ts.PropertyAccessExpression; const exprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode); const baseExprSym = this.tsUtils.trueSymbolAtLocation(propertyAccessNode.expression); @@ -1412,6 +1224,36 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private isJsRelated(node: ts.Expression): boolean { + if (this.tsUtils.isJsImport(node)) { + return true; + } + + if (ts.isNewExpression(node)) { + return this.tsUtils.isJsImport(node.expression); + } + + if (ts.isIdentifier(node)) { + const symbol = this.tsUtils.trueSymbolAtLocation(node); + if (!symbol) { + return false; + } + + const declarations = symbol.getDeclarations(); + if (!declarations || declarations.length === 0) { + return false; + } + + for (const declaration of declarations) { + if (ts.isVariableDeclaration(declaration) && declaration.initializer) { + return this.isJsRelated(declaration.initializer); + } + } + } + + return false; + } + propertyAccessExpressionForInterop(propertyAccessNode: ts.PropertyAccessExpression): void { if (!this.useStatic || !this.options.arkts2) { return; @@ -1424,20 +1266,28 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return current; - } + }; const firstObjNode = getFirstObjectNode(propertyAccessNode); - const isFromJs = this.tsUtils.isJsImport(firstObjNode); + const isJsObject = this.isJsRelated(firstObjNode); + if (!isJsObject) { + return; + } - if(isFromJs) { - if (ts.isBinaryExpression(propertyAccessNode.parent) && - propertyAccessNode.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken) { - const autofix = this.autofixer?.fixInteropBinaryExpression(propertyAccessNode.parent); - this.incrementCounters(propertyAccessNode.parent, FaultID.InteropObjectProperty, autofix); - } else { - const autofix = this.autofixer?.fixInteropPropertyAccessExpression(propertyAccessNode); - this.incrementCounters(propertyAccessNode, FaultID.InteropObjectProperty, autofix); - } + if (ts.isBinaryExpression(propertyAccessNode.parent)) { + const isAssignment = propertyAccessNode.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken; + const autofix = isAssignment ? + this.autofixer?.fixInteropBinaryExpression(propertyAccessNode.parent) : + this.autofixer?.fixInteropPropertyAccessExpression(propertyAccessNode); + + this.incrementCounters( + isAssignment ? propertyAccessNode.parent : propertyAccessNode, + FaultID.InteropObjectProperty, + autofix + ); + } else { + const autofix = this.autofixer?.fixInteropPropertyAccessExpression(propertyAccessNode); + this.incrementCounters(propertyAccessNode, FaultID.InteropObjectProperty, autofix); } } @@ -1448,36 +1298,31 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isCallExpression(node.parent)) { return; } - const methodName = node.name.getText(); if (methodName !== ISCONCURRENT) { return; } - - const symbol = this.tsUtils.trueSymbolAtLocation(node.expression); - if (!symbol) { + const moduleSpecifier = this.findModuleSpecifierforDepricatedIsConcurrent(node); + if (!moduleSpecifier || !ts.isStringLiteral(moduleSpecifier)) { return; } + if ( + TASKPOOL_MODULES.some((moduleName) => { + return TsUtils.removeOrReplaceQuotes(moduleSpecifier.getText(), false) === moduleName; + }) + ) { + this.incrementCounters(node.name, FaultID.IsConcurrentDeprecated); + } + } - if (symbol.name === TASKPOOL) { - const decl = TsUtils.getDeclaration(symbol); - - if (!decl) { - return; - } - - const sourceFile = decl.getSourceFile(); - const fileName = path.basename(sourceFile.fileName); - - if ( - TASKPOOL_MODULES.some((moduleName) => { - return fileName.startsWith(moduleName); - }) - ) { - this.incrementCounters(node.name, FaultID.IsConcurrentDeprecated); - } + findModuleSpecifierforDepricatedIsConcurrent(node: ts.PropertyAccessExpression): ts.Expression | undefined { + let symbol = this.tsUtils.trueSymbolAtLocation(node.expression); + if (symbol && 'unknown' === symbol.name) { + symbol = this.tsTypeChecker.getSymbolAtLocation(node.expression); } + const importDecl = ts.findAncestor(TsUtils.getDeclaration(symbol), ts.isImportDeclaration); + return importDecl?.moduleSpecifier; } checkFunctionProperty( @@ -1588,8 +1433,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); const classDecorators = ts.getDecorators(node.parent); const propType = node.type?.getText(); - if (this.options.arkts2 && propType === 'void' && node.type) { - this.incrementCounters(node.type, FaultID.LimitedVoidType); + if (this.options.arkts2 && node.type && TsUtils.typeContainsVoid(node.type)) { + const autofix = this.autofixer?.fixLimitedVoidType(node); + this.incrementCounters(node.type, FaultID.LimitedVoidType, autofix); } this.filterOutDecoratorsDiagnostics( classDecorators, @@ -1609,7 +1455,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleInvalidIdentifier(node); this.handleStructPropertyDecl(node); this.handlePropertyDeclarationForProp(node); - this.handleSdkDuplicateDeclName(node); + this.handleSdkGlobalApi(node); this.handleObjectLiteralAssignmentToClass(node); } @@ -1634,6 +1480,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handlePropertyAssignment(node: ts.PropertyAssignment): void { this.handleDollarBind(node); + this.handlePropertyAssignmentForProp(node); this.handleQuotedHyphenPropsDeprecated(node); const propName = node.name; @@ -1863,6 +1710,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (hasUnfixableReturnType) { this.incrementCounters(funcExpr, FaultID.LimitedReturnTypeInference); } + this.handleLimitedVoidFunction(funcExpr); } private handleArrowFunction(node: ts.Node): void { @@ -1877,6 +1725,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } this.checkDefaultParamBeforeRequired(arrowFunc); + this.handleLimitedVoidFunction(arrowFunc); } private handleFunctionDeclaration(node: ts.Node): void { @@ -1922,6 +1771,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkAssignmentNumericSemanticsFuntion(tsFunctionDeclaration); this.handleInvalidIdentifier(tsFunctionDeclaration); this.checkDefaultParamBeforeRequired(tsFunctionDeclaration); + this.handleLimitedVoidFunction(tsFunctionDeclaration); } private handleMissingReturnType( @@ -2037,7 +1887,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const propertyAccess = ts.isParenthesizedExpression(expr) ? expr.expression : expr; if (ts.isPropertyAccessExpression(propertyAccess)) { - const exprSym = this.tsUtils.trueSymbolAtLocation(propertyAccess); + const exprSym = this.tsUtils.trueSymbolAtLocation(propertyAccess.expression); const declaration = exprSym?.declarations?.[0]; this.checkAndProcessDeclaration(declaration, tsUnaryArithm); } @@ -2131,8 +1981,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkAssignmentMatching(tsBinaryExpr, leftOperandType, tsRhsExpr); this.checkFunctionTypeCompatible(typeNode, tsRhsExpr); this.handleEsObjectAssignment(tsBinaryExpr, typeNode, tsRhsExpr); - this.handleSdkDuplicateDeclName(tsBinaryExpr); - this.checkArrayTypeImmutable(tsBinaryExpr); + this.handleSdkGlobalApi(tsBinaryExpr); break; case ts.SyntaxKind.AmpersandAmpersandEqualsToken: case ts.SyntaxKind.QuestionQuestionEqualsToken: @@ -2158,7 +2007,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const processExpression = (expr: ts.Expression): void => { const symbol = this.tsUtils.trueSymbolAtLocation(expr); if (this.isJsFileSymbol(symbol) || this.isJsFileExpression(expr)) { - this.incrementCounters(expr, FaultID.InterOpImportJsDataCompare); + const autofix = this.autofixer?.fixInteropOperators(expr); + this.incrementCounters(expr, FaultID.InterOpImportJsDataCompare, autofix); } }; @@ -2576,45 +2426,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleObjectLiteralAssignmentToClass(tsVarDecl); this.handleObjectLiteralAssignment(tsVarDecl); this.handlePropertyDescriptorInScenarios(tsVarDecl); - this.handleSdkDuplicateDeclName(tsVarDecl); - this.checkArrayTypeImmutable(tsVarDecl); - } - - private checkArrayTypeImmutable(node: ts.VariableDeclaration | ts.BinaryExpression): void { - if (!this.options.arkts2) { - return; - } - if (ts.isVariableDeclaration(node)) { - if (!node.initializer || ts.isArrayLiteralExpression(node.initializer)) { - return; - } - if (node.type && ts.isArrayTypeNode(node.type)) { - const varDeclType = this.tsTypeChecker.typeToString(this.tsTypeChecker.getTypeAtLocation(node.name)); - const initializerType = this.tsTypeChecker.typeToString(this.tsTypeChecker.getTypeAtLocation(node.initializer)); - if (varDeclType !== initializerType) { - this.incrementCounters(node, FaultID.ArrayTypeImmutable); - } - } - } else { - this.checkArrayTypeImmutableForBinaryExpression(node); - } - } - - private checkArrayTypeImmutableForBinaryExpression(node: ts.BinaryExpression): void { - const sym = this.tsTypeChecker.getSymbolAtLocation(node.left); - const declaration = sym?.declarations?.[0]; - if ( - declaration && - (ts.isVariableDeclaration(declaration) || ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration)) - ) { - if (declaration.type && ts.isArrayTypeNode(declaration.type) && !ts.isArrayLiteralExpression(node.right)) { - const leftType = this.tsTypeChecker.typeToString(this.tsTypeChecker.getTypeAtLocation(node.left)); - const rightType = this.tsTypeChecker.typeToString(this.tsTypeChecker.getTypeAtLocation(node.right)); - if (leftType !== rightType) { - this.incrementCounters(node, FaultID.ArrayTypeImmutable); - } - } - } + this.handleSdkGlobalApi(tsVarDecl); } private checkTypeFromSdk(type: ts.TypeNode | undefined): void { @@ -2917,12 +2729,25 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.CatchWithUnsupportedType, autofix); } - if ( - this.options.arkts2 && - tsCatch.variableDeclaration && - TsUtils.isAnyType(this.tsTypeChecker.getTypeAtLocation(tsCatch.variableDeclaration)) - ) { - this.incrementCounters(node, FaultID.TsLikeCatchType); + if (this.options.arkts2 && tsCatch.variableDeclaration?.name) { + const varDeclName = tsCatch.variableDeclaration?.name.getText(); + tsCatch.block.statements.forEach((statement) => { + this.checkTsLikeCatchType(statement, varDeclName); + }); + } + } + + private checkTsLikeCatchType(node: ts.Node, variableDeclarationName: string): void { + if (!node) { + return; + } + for (const child of node.getChildren()) { + if (ts.isPropertyAccessExpression(child)) { + if (child.expression.getText() === variableDeclarationName && !ERROR_PROP_LIST.has(child.name.getText())) { + this.incrementCounters(child, FaultID.TsLikeCatchType); + } + } + this.checkTsLikeCatchType(child, variableDeclarationName); } } @@ -3035,6 +2860,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { methodName?: string ): boolean { return heritageClause.types.some((type) => { + const parentName = ts.isPropertyAccessExpression(type.expression) ? + type.expression.name.text : + type.expression.getText(); const fullTypeName = TypeScriptLinter.findFinalExpression(type).getText(); const sdkInfos = this.interfaceMap.get(fullTypeName); if (!sdkInfos || sdkInfos.size === 0) { @@ -3046,7 +2874,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } - if (!methodName) { + if (!methodName && sdkInfo.parent_api[0].api_name === parentName) { this.processSdkInfoWithMembers(sdkInfo, tsClassDecl.members, tsClassDecl); return false; } @@ -3108,12 +2936,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ): boolean { const apiParamCout = sdkFuncArgs.length; const memberParamCout = memberParams.length; - if (apiParamCout > memberParamCout && sdkFuncArgs[memberParamCout + 1]) { + if (apiParamCout > memberParamCout && sdkFuncArgs[memberParamCout]) { return false; } for (let i = 0; i < apiParamCout; i++) { - const typeName = memberParams[i].type?.getText(); + const typeName = memberParams[i]?.type?.getText(); if (!typeName?.match(sdkFuncArgs[i].type)) { return false; } @@ -3496,6 +3324,22 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } this.checkDefaultParamBeforeRequired(tsMethodDecl); this.handleMethodInherit(tsMethodDecl); + this.handleSdkGlobalApi(tsMethodDecl); + this.handleLimitedVoidFunction(tsMethodDecl); + } + + private handleLimitedVoidFunction(node: ts.FunctionLikeDeclaration): void { + const typeNode = node.type; + if (!typeNode || !ts.isUnionTypeNode(typeNode)) { + return; + } + const containsVoid = typeNode.types.some((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword; + }); + if (this.options.arkts2 && containsVoid) { + const autofix = this.autofixer?.fixLimitedVoidTypeFunction(node); + this.incrementCounters(typeNode, FaultID.LimitedVoidType, autofix); + } } private checkDefaultParamBeforeRequired(node: ts.FunctionLikeDeclarationBase): void { @@ -3533,42 +3377,73 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const classType = this.tsTypeChecker.getTypeAtLocation(classDecl); - const baseTypes = classType.getBaseTypes(); - if (!baseTypes || baseTypes.length === 0) { + const allBaseTypes = this.getAllBaseTypes(classType, classDecl); + if (!allBaseTypes || allBaseTypes.length === 0) { return; } const methodName = node.name.text; - for (const baseType of baseTypes) { + for (const baseType of allBaseTypes) { const baseMethod = baseType.getProperty(methodName); if (!baseMethod) { continue; } - const baseMethodDecl = baseMethod.declarations?.find(ts.isMethodDeclaration); + const baseMethodDecl = baseMethod.declarations?.find((d) => { + return ts.isMethodDeclaration(d) || ts.isMethodSignature(d); + }) as ts.MethodDeclaration | ts.MethodSignature | undefined; + if (!baseMethodDecl) { continue; } - // Check parameter compatibility this.checkMethodParameters(node, baseMethodDecl); - // Check return type compatibility this.checkMethodReturnType(node, baseMethodDecl); break; } } + private getAllBaseTypes(type: ts.Type, classDecl: ts.ClassDeclaration): ts.Type[] | undefined { + const baseClasses = type.getBaseTypes() || []; + if (!classDecl.heritageClauses) { + return baseClasses; + } + const interfaces: ts.Type[] = []; + for (const clause of classDecl.heritageClauses) { + if (clause.token !== ts.SyntaxKind.ImplementsKeyword) { + continue; + } + for (const typeNode of clause.types) { + const interfaceType = this.tsTypeChecker.getTypeAtLocation(typeNode); + interfaces.push(interfaceType); + const parentInterfaces = interfaceType.getBaseTypes(); + if (parentInterfaces) { + interfaces.push(...parentInterfaces); + } + } + } + return [...baseClasses, ...interfaces]; + } + /** - * Checks if child parameters accept at least as many types as parent parameters. - * (Child parameter type should be same or wider than parent.) + * Checks method parameter compatibility + * Derived parameter types must be same or wider than base (contravariance principle) */ - private checkMethodParameters(derivedMethod: ts.MethodDeclaration, baseMethod: ts.MethodDeclaration): void { + private checkMethodParameters( + derivedMethod: ts.MethodDeclaration, + baseMethod: ts.MethodDeclaration | ts.MethodSignature + ): void { const derivedParams = derivedMethod.parameters; const baseParams = baseMethod.parameters; + if (derivedParams.length !== baseParams.length) { + this.incrementCounters(derivedMethod.name, FaultID.MethodInheritRule); + return; + } + const paramCount = Math.min(derivedParams.length, baseParams.length); for (let i = 0; i < paramCount; i++) { @@ -3582,15 +3457,27 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } /** - * Checks return type covariance between base and derived methods. - * (Derived return type must be assignable to base return type.) + * Checks return type compatibility + * Derived return type must be same or narrower than base (covariance principle) */ - private checkMethodReturnType(derivedMethod: ts.MethodDeclaration, baseMethod: ts.MethodDeclaration): void { - if (!baseMethod.type || !derivedMethod.type) { + private checkMethodReturnType( + derivedMethod: ts.MethodDeclaration, + baseMethod: ts.MethodDeclaration | ts.MethodSignature + ): void { + if ( + this.IsVoidTypeOnActualReturnType(baseMethod) && + derivedMethod.type && + !this.IsVoidTypeOnActualReturnType(derivedMethod) + ) { + this.incrementCounters(derivedMethod.type, FaultID.MethodInheritRule); return; } - const baseReturnType = this.tsTypeChecker.getTypeAtLocation(baseMethod.type); + if (!baseMethod.type || !derivedMethod.type) { + return; + } + + const baseReturnType = this.tsTypeChecker.getTypeAtLocation(baseMethod.type); const derivedReturnType = this.tsTypeChecker.getTypeAtLocation(derivedMethod.type); if (!this.isTypeAssignable(derivedReturnType, baseReturnType)) { @@ -3598,6 +3485,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private IsVoidTypeOnActualReturnType(method: ts.MethodDeclaration | ts.MethodSignature): boolean | undefined { + let type: ts.Type | undefined; + if (method.type) { + type = this.tsTypeChecker.getTypeAtLocation(method.type); + } else { + const signature = this.tsTypeChecker.getSignatureFromDeclaration(method); + if (signature) { + type = this.tsTypeChecker.getReturnTypeOfSignature(signature); + } + } + return type && TsUtils.isVoidType(type); + } + /** * Child type should include all types of parent type (be same or wider). * Returns true if every type in baseType is also included in derivedType. @@ -3847,7 +3747,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleGlobalThisCase(node: ts.Identifier, isArkTs2: boolean | undefined): void { let faultId = FaultID.GlobalThis; - let autofix: Autofix[] | undefined; let targetNode: ts.Node = node; if (!isArkTs2) { @@ -3864,14 +3763,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { parentExpression.operatorToken.kind === ts.SyntaxKind.EqualsToken ) { targetNode = parentExpression; - autofix = this.autofixer?.fixGlobalThisSet(targetNode as ts.BinaryExpression); } else { targetNode = node.parent; - autofix = this.autofixer?.fixGlobalThisGet(targetNode as ts.PropertyAccessExpression); } } - this.incrementCounters(targetNode, faultId, autofix); + this.incrementCounters(targetNode, faultId); } // hard-coded alternative to TypeScriptLinter.advancedClassChecks @@ -3963,12 +3860,20 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + this.handleIllegalSymbolUsage(tsIdentifier, tsIdentSym); + } + + private handleIllegalSymbolUsage(tsIdentifier: ts.Identifier, tsIdentSym: ts.Symbol): void { if (tsIdentSym.flags & ts.SymbolFlags.ValueModule) { this.incrementCounters(tsIdentifier, FaultID.NamespaceAsObject); } else { - // missing EnumAsObject - const faultId = this.options.arkts2 ? FaultID.ClassAsObjectError : FaultID.ClassAsObject; - this.incrementCounters(tsIdentifier, faultId); + const typeName = tsIdentifier.getText(); + const isWrapperObject = typeName === 'Number' || typeName === 'String' || typeName === 'Boolean'; + + if (!isWrapperObject) { + const faultId = this.options.arkts2 ? FaultID.ClassAsObjectError : FaultID.ClassAsObject; + this.incrementCounters(tsIdentifier, faultId); + } } } @@ -4093,7 +3998,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - const argExpr = TypeScriptLinter.getUnwrappedArgumentExpression(expr.argumentExpression); const validStringLiteralTypes = [ STRINGLITERAL_INT, STRINGLITERAL_BYTE, @@ -4104,19 +4008,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const argTypeString = this.tsTypeChecker.typeToString(argType); if (this.tsUtils.isNumberLikeType(argType)) { - this.handleNumericArgument(argExpr, expr.argumentExpression, argType); + this.handleNumericArgument(expr.argumentExpression, argType); } else if (!validStringLiteralTypes.includes(argTypeString)) { - this.incrementCounters(argExpr, FaultID.ArrayIndexExprType); + this.incrementCounters(expr.argumentExpression, FaultID.ArrayIndexExprType); } } - private static getUnwrappedArgumentExpression(argExpr: ts.Expression): ts.Expression { - return argExpr.kind === ts.SyntaxKind.AsExpression ? (argExpr as ts.AsExpression).expression : argExpr; - } - - private handleNumericArgument(argExpr: ts.Expression, asExpr: ts.Expression, argType: ts.Type): void { + private handleNumericArgument(argExpr: ts.Expression, argType: ts.Type): void { const isNumericLiteral = ts.isNumericLiteral(argExpr); - const isAsExpression = asExpr.kind === ts.SyntaxKind.AsExpression; const argText = argExpr.getText(); const argValue = Number(argText); @@ -4125,7 +4024,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const containsDot = argText.includes('.'); if (!isInteger || containsDot) { - const autofix = this.autofixer?.fixArrayIndexExprType(isAsExpression ? asExpr : argExpr); + const autofix = this.autofixer?.fixArrayIndexExprType(argExpr); this.incrementCounters(argExpr, FaultID.ArrayIndexExprType, autofix); } } else if (this.tsTypeChecker.typeToString(argType) === 'number') { @@ -4479,9 +4378,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleInteropForCallJSExpression(tsCallExpr, calleeSym, callSignature); this.handleNoTsLikeFunctionCall(tsCallExpr); this.handleObjectLiteralInFunctionArgs(tsCallExpr); - this.handleTaskPoolDeprecatedUsages(tsCallExpr); - this.handleSdkDuplicateDeclName(tsCallExpr); + this.handleSdkGlobalApi(tsCallExpr); this.handleObjectLiteralAssignmentToClass(tsCallExpr); + this.checkRestrictedAPICall(tsCallExpr); } handleNoTsLikeFunctionCall(callExpr: ts.CallExpression): void { @@ -4556,13 +4455,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.options.arkts2 || !this.useStatic) { return; } - - // Typeof expressions is handled by a different rule, early return if parent is a typeof expression - if (ts.isTypeOfExpression(tsCallExpr.parent)) { + if (ts.isAwaitExpression(tsCallExpr.parent) || ts.isTypeOfExpression(tsCallExpr.parent)) { return; } - if (!callSignature || TypeScriptLinter.isDeclaredInArkTs2(callSignature)) { + if (!callSignature || this.isDeclaredInArkTs2(callSignature)) { return; } @@ -4589,7 +4486,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - if (!TypeScriptLinter.isDeclaredInArkTs2(callSignature)) { + if (!this.isDeclaredInArkTs2(callSignature)) { return; } @@ -4648,7 +4545,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } - private static isDeclaredInArkTs2(callSignature: ts.Signature): boolean | undefined { + private isDeclaredInArkTs2(callSignature: ts.Signature): boolean | undefined { const declarationSourceFile = callSignature?.declaration?.getSourceFile(); if (!declarationSourceFile) { return undefined; @@ -4656,13 +4553,44 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!declarationSourceFile.statements) { return undefined; } - // check for 'use static' at the start of the file this function declared at - if (declarationSourceFile.statements[0].getText() === USE_STATIC) { + + if (this.tsUtils.isArkts12File(declarationSourceFile)) { return true; } return false; } + private checkRestrictedAPICall(node: ts.Node): void { + if (ts.isCallExpression(node)) { + if (TypeScriptLinter.isReflectAPICall(node)) { + this.incrementCounters(node.parent, FaultID.InteropCallReflect); + return; + } + + const signature = this.tsTypeChecker.getResolvedSignature(node); + if (signature) { + this.checkForForbiddenAPIs(signature, node); + } + } + } + + static isReflectAPICall(callExpr: ts.CallExpression): boolean { + if (ts.isPropertyAccessExpression(callExpr.expression)) { + const expr = callExpr.expression.expression; + if (ts.isIdentifier(expr) && expr.text === REFLECT_LITERAL) { + return true; + } + } + + if (ts.isElementAccessExpression(callExpr.expression)) { + const expr = callExpr.expression.expression; + if (ts.isIdentifier(expr) && expr.text === REFLECT_LITERAL) { + return true; + } + } + return false; + } + private checkForForbiddenAPIs(callSignature: ts.Signature, tsCallExpr: ts.CallExpression): void { if (!callSignature.declaration) { return; @@ -4677,6 +4605,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!TypeScriptLinter.isFunctionLike(functionDeclaration)) { return; } + switch (TypeScriptLinter.containsForbiddenAPI(functionDeclaration)) { case REFLECT_LITERAL: this.incrementCounters(tsCallExpr.parent, FaultID.InteropCallReflect); @@ -4780,29 +4709,92 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } const resolvedTypeArgs = signDecl.typeArguments; - const startTypeArg = callLikeExpr.typeArguments?.length ?? 0; + const providedTypeArgs = callLikeExpr.typeArguments; + const startTypeArg = providedTypeArgs?.length ?? 0; + let shouldReportError = startTypeArg !== resolvedTypeArgs.length; if (this.options.arkts2 && callLikeExpr.kind === ts.SyntaxKind.NewExpression) { - if (startTypeArg !== resolvedTypeArgs.length) { + shouldReportError = this.shouldReportGenericTypeArgsError( + callLikeExpr, + resolvedTypeArgs, + providedTypeArgs, + startTypeArg, + shouldReportError + ); + if (shouldReportError) { const autofix = this.autofixer?.fixGenericCallNoTypeArgs(callLikeExpr); this.incrementCounters(callLikeExpr, FaultID.GenericCallNoTypeArgs, autofix); } } else { - for (let i = startTypeArg; i < resolvedTypeArgs.length; ++i) { - const typeNode = resolvedTypeArgs[i]; + this.checkForUnknownTypeInNonArkTS2(callLikeExpr, resolvedTypeArgs, startTypeArg); + } + } - /* - * if compiler infers 'unknown' type there are 2 possible cases: - * 1. Compiler unable to infer type from arguments and use 'unknown' - * 2. Compiler infer 'unknown' from arguments - * We report error in both cases. It is ok because we cannot use 'unknown' - * in ArkTS and already have separate check for it. - */ - if (typeNode.kind === ts.SyntaxKind.UnknownKeyword) { - this.incrementCounters(callLikeExpr, FaultID.GenericCallNoTypeArgs); - break; - } + private checkForUnknownTypeInNonArkTS2( + callLikeExpr: ts.CallExpression | ts.NewExpression, + resolvedTypeArgs: ts.NodeArray, + startTypeArg: number + ): void { + for (let i = startTypeArg; i < resolvedTypeArgs.length; ++i) { + const typeNode = resolvedTypeArgs[i]; + + /* + * if compiler infers 'unknown' type there are 2 possible cases: + * 1. Compiler unable to infer type from arguments and use 'unknown' + * 2. Compiler infer 'unknown' from arguments + * We report error in both cases. It is ok because we cannot use 'unknown' + * in ArkTS and already have separate check for it. + */ + if (typeNode.kind === ts.SyntaxKind.UnknownKeyword) { + this.incrementCounters(callLikeExpr, FaultID.GenericCallNoTypeArgs); + break; + } + } + } + + private shouldReportGenericTypeArgsError( + callLikeExpr: ts.CallExpression | ts.NewExpression, + resolvedTypeArgs: ts.NodeArray, + providedTypeArgs: ts.NodeArray | undefined, + startTypeArg: number, + initialErrorState: boolean + ): boolean { + const typeParameters = this.getOriginalTypeParameters(callLikeExpr); + if (!typeParameters || typeParameters.length === 0) { + return initialErrorState; + } + const optionalParamsCount = typeParameters.filter((param, index) => { + return param.default && (!providedTypeArgs || index >= providedTypeArgs.length); + }).length; + if (optionalParamsCount === 0) { + return initialErrorState; + } + return startTypeArg + optionalParamsCount !== resolvedTypeArgs.length; + } + + private getOriginalTypeParameters( + callLikeExpr: ts.CallExpression | ts.NewExpression + ): ts.TypeParameterDeclaration[] | undefined { + const typeChecker = this.tsTypeChecker; + const expressionType = typeChecker.getTypeAtLocation(callLikeExpr.expression); + const declarations = expressionType.symbol?.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + for (const decl of declarations) { + if (ts.isFunctionDeclaration(decl) && decl.typeParameters) { + return [...decl.typeParameters]; + } + if (ts.isMethodDeclaration(decl) && decl.typeParameters) { + return [...decl.typeParameters]; + } + if (ts.isClassDeclaration(decl) && decl.typeParameters) { + return [...decl.typeParameters]; + } + if (ts.isInterfaceDeclaration(decl) && decl.typeParameters) { + return [...decl.typeParameters]; } } + return undefined; } private isNonGenericClass(expression: ts.NewExpression): boolean { @@ -5007,17 +4999,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); } - private checkConstrutorAccess(newExpr: ts.NewExpression): void { + private checkConstrutorAccess(propertyAccessExpr: ts.PropertyAccessExpression): void { if (!this.options.arkts2 || !this.useStatic) { return; } - if (!ts.isPropertyAccessExpression(newExpr.parent)) { - return; - } - - if (newExpr.parent.name.text === 'constructor') { - this.incrementCounters(newExpr.parent, FaultID.NoConstructorOnClass); + if (propertyAccessExpr.name.text === 'constructor') { + this.incrementCounters(propertyAccessExpr, FaultID.NoConstructorOnClass); } } @@ -5036,9 +5024,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const type = this.tsTypeChecker.getTypeAtLocation(calleeExpr); - if (type.isClassOrInterface()) { - this.incrementCounters(calleeExpr, FaultID.ConstructorIfaceFromSdk); + if (!type.symbol) { + return; + } + const typeDeclarations = type.symbol.declarations; + if (!typeDeclarations || typeDeclarations.length === 0) { + return; + } + + if (!ts.isInterfaceDeclaration(typeDeclarations[0])) { + return; } + + this.incrementCounters(calleeExpr, FaultID.ConstructorIfaceFromSdk); } private handleNewExpression(node: ts.Node): void { @@ -5046,8 +5044,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkForInterfaceInitialization(tsNewExpr); this.handleSharedArrayBuffer(tsNewExpr); - this.handleSdkDuplicateDeclName(tsNewExpr); - this.checkConstrutorAccess(tsNewExpr); + this.handleSdkGlobalApi(tsNewExpr); this.checkCreatingPrimitiveTypes(tsNewExpr); if (this.options.advancedClassChecks || this.options.arkts2) { @@ -5146,6 +5143,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.options.arkts2 && this.tsUtils.needToDeduceStructuralIdentity(targetType, exprType, tsAsExpr.expression, true) ) { + if (this.isExemptedAsExpression(tsAsExpr)) { + return; + } if (!this.tsUtils.isObject(exprType)) { this.incrementCounters(node, FaultID.StructuralIdentity); } @@ -5153,6 +5153,42 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleAsExpressionImport(tsAsExpr); this.handleNoTuplesArrays(node, targetType, exprType); this.handleObjectLiteralAssignmentToClass(tsAsExpr); + this.handleArrayTypeImmutable(tsAsExpr, exprType, targetType); + } + + private isExemptedAsExpression(node: ts.AsExpression): boolean { + if (!ts.isElementAccessExpression(node.expression)) { + return false; + } + + const sourceType = this.tsTypeChecker.getTypeAtLocation(node.expression); + const targetType = this.tsTypeChecker.getTypeAtLocation(node.type); + const isRecordIndexAccess = (): boolean => { + const exprType = this.tsTypeChecker.getTypeAtLocation(node.expression); + const hasNumberIndex = !!exprType.getNumberIndexType(); + const hasStringIndex = !!exprType.getStringIndexType(); + const hasBooleanIndex = !!exprType.getProperty('true') || !!exprType.getProperty('false'); + + return hasNumberIndex || hasStringIndex || hasBooleanIndex; + }; + + if (isRecordIndexAccess()) { + const targetSymbol = targetType.getSymbol(); + if (targetSymbol && targetSymbol.getName() === 'Array') { + return true; + } + } + const primitiveFlags = ts.TypeFlags.Number | ts.TypeFlags.String | ts.TypeFlags.Boolean; + const objectFlag = ts.TypeFlags.Object; + return ( + sourceType.isUnion() && + sourceType.types.some((t) => { + return t.flags & primitiveFlags; + }) && + sourceType.types.some((t) => { + return t.flags & objectFlag; + }) + ); } private handleAsExpressionImport(tsAsExpr: ts.AsExpression): void { @@ -5230,7 +5266,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private handleSharedArrayBuffer(node: ts.TypeReferenceNode | ts.NewExpression): void { + private handleSharedArrayBuffer( + node: ts.TypeReferenceNode | ts.NewExpression | ts.ExpressionWithTypeArguments + ): void { if (!this.options.arkts2) { return; } @@ -5239,22 +5277,40 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isIdentifier(typeNameIdentifier) || typeNameIdentifier.getText() !== ESLIB_SHAREDARRAYBUFFER) { return; } + const symbol = this.tsUtils.trueSymbolAtLocation(typeNameIdentifier); + if (!symbol) { + return; + } + + const isImported = this.sourceFile.statements.some((stmt) => { + if (!ts.isImportDeclaration(stmt)) { + return false; + } + const importClause = stmt.importClause; + if (!importClause?.namedBindings || !ts.isNamedImports(importClause.namedBindings)) { + return false; + } - const decls = this.tsUtils.trueSymbolAtLocation(typeNameIdentifier)?.getDeclarations(); + const elements = importClause.namedBindings.elements.some((element) => { + return element.name.text === ESLIB_SHAREDARRAYBUFFER; + }); + return elements; + }); + if (isImported) { + return; + } + const decls = symbol.getDeclarations(); const isSharedMemoryEsLib = decls?.some((decl) => { const srcFileName = decl.getSourceFile().fileName; return srcFileName.endsWith(ESLIB_SHAREDMEMORY_FILENAME); }); + if (!isSharedMemoryEsLib || this.hasLocalSharedArrayBufferClass()) { return; } - if (ts.isNewExpression(node)) { - const autofix = this.autofixer?.fixSharedArrayBufferConstructor(node); - this.incrementCounters(node.expression, FaultID.SharedArrayBufferDeprecated, autofix); - } else { - const autofix = this.autofixer?.fixSharedArrayBufferTypeReference(node); - this.incrementCounters(node, FaultID.SharedArrayBufferDeprecated, autofix); - } + + const autofix = this.autofixer?.replaceNode(typeNameIdentifier, 'ArrayBuffer'); + this.incrementCounters(typeNameIdentifier, FaultID.SharedArrayBufferDeprecated, autofix); } private hasLocalSharedArrayBufferClass(): boolean { @@ -5268,7 +5324,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleBuiltinCtorCallSignature(typeRef); this.handleSharedArrayBuffer(typeRef); - this.handleSdkDuplicateDeclName(typeRef); + this.handleSdkGlobalApi(typeRef); this.handleSdkConstructorIface(typeRef); @@ -5298,6 +5354,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } this.checkNoEnumProp(typeRef); + if (ts.isQualifiedName(typeRef.typeName)) { + this.handleSdkForConstructorFuncs(typeRef.typeName); + } } private checkNoEnumProp(typeRef: ts.TypeReferenceNode): void { @@ -5401,7 +5460,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const faultId = this.options.arkts2 ? FaultID.EsValueTypeError : FaultID.EsValueType; this.incrementCounters(tsTypeExpr, faultId); } - this.handleSdkDuplicateDeclName(tsTypeExpr); + this.handleSdkGlobalApi(tsTypeExpr); } private handleComputedPropertyName(node: ts.Node): void { @@ -5655,6 +5714,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleConstructorDeclaration(node: ts.Node): void { const ctorDecl = node as ts.ConstructorDeclaration; + this.checkDefaultParamBeforeRequired(ctorDecl); this.handleTSOverload(ctorDecl); const paramProperties = ctorDecl.parameters.filter((x) => { return this.tsUtils.hasAccessModifier(x); @@ -5931,6 +5991,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ): void { const rhsType = this.tsTypeChecker.getTypeAtLocation(rhsExpr); this.handleNoTuplesArrays(field, lhsType, rhsType); + this.handleArrayTypeImmutable(field, lhsType, rhsType, rhsExpr); // check that 'sendable typeAlias' is assigned correctly if (this.tsUtils.isWrongSendableFunctionAssignment(lhsType, rhsType)) { this.incrementCounters(field, FaultID.SendableFunctionAssignment); @@ -5941,6 +6002,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } if (this.tsUtils.needToDeduceStructuralIdentity(lhsType, rhsType, rhsExpr, isStrict)) { + if (ts.isNewExpression(rhsExpr) && ts.isIdentifier(rhsExpr.expression) && rhsExpr.expression.text === 'Promise') { + const isReturnStatement = ts.isReturnStatement(rhsExpr.parent); + const enclosingFunction = ts.findAncestor(rhsExpr, ts.isFunctionLike); + const isAsyncFunction = + enclosingFunction && + (enclosingFunction.modifiers?.some((m) => { + return m.kind === ts.SyntaxKind.AsyncKeyword; + }) || + false); + if (isReturnStatement && isAsyncFunction) { + return; + } + } this.incrementCounters(field, FaultID.StructuralIdentity); } } @@ -6044,8 +6118,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const typeNode = node.type; - if (typeNode && typeNode.kind === ts.SyntaxKind.VoidKeyword) { - this.incrementCounters(typeNode, FaultID.LimitedVoidType); + if (typeNode && TsUtils.typeContainsVoid(typeNode)) { + const autofix = this.autofixer?.fixLimitedVoidType(node); + this.incrementCounters(typeNode, FaultID.LimitedVoidType, autofix); } } @@ -6059,12 +6134,44 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const signature = this.tsTypeChecker.getResolvedSignature(node); - if (signature) { - const returnType = this.tsTypeChecker.getReturnTypeOfSignature(signature); - if (this.tsTypeChecker.typeToString(returnType) === 'void') { + if (!signature) { + return; + } + + const returnType = this.tsTypeChecker.getReturnTypeOfSignature(signature); + if (this.tsTypeChecker.typeToString(returnType) !== 'void') { + return; + } + + if (ts.isReturnStatement(node.parent)) { + const functionLike = TypeScriptLinter.findContainingFunction(node); + if (functionLike && TypeScriptLinter.isRecursiveCall(node, functionLike)) { this.incrementCounters(node, FaultID.LimitedVoidType); } + return; + } + + this.incrementCounters(node, FaultID.LimitedVoidType); + } + + private static findContainingFunction(node: ts.Node): ts.FunctionLikeDeclaration | undefined { + while (node) { + if (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isArrowFunction(node)) { + return node; + } + node = node.parent; } + return undefined; + } + + // Helper function to check if a call is recursive + private static isRecursiveCall(callExpr: ts.CallExpression, fn: ts.FunctionLikeDeclaration): boolean { + return ( + ts.isIdentifier(callExpr.expression) && + ts.isFunctionDeclaration(fn) && + !!fn.name && + fn.name.text === callExpr.expression.text + ); } private handleArrayType(arrayType: ts.Node): void { @@ -6102,8 +6209,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.options.arkts2) { return; } - const autofix = this.autofixer?.fixDebuggerStatement(node as ts.DebuggerStatement); - this.incrementCounters(node, FaultID.DebuggerStatement, autofix); + + this.incrementCounters(node, FaultID.DebuggerStatement); } private handleTSOverload(decl: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ConstructorDeclaration): void { @@ -6450,6 +6557,67 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private handleNoTuplesArraysForPropertyAccessExpression(node: ts.PropertyAccessExpression): void { + if (!this.options.arkts2) { + return; + } + const lhsType = this.tsTypeChecker.getTypeAtLocation(node.expression); + if (this.tsUtils.isOrDerivedFrom(lhsType, TsUtils.isTuple)) { + if (ARRAY_API_LIST.includes(node.name.text)) { + this.incrementCounters(node, FaultID.NoTuplesArrays); + } + } + } + + private handleArrayTypeImmutable(node: ts.Node, lhsType: ts.Type, rhsType: ts.Type, rhsExpr?: ts.Expression): void { + if (!this.options.arkts2) { + return; + } + if ( + !( + this.tsUtils.isOrDerivedFrom(lhsType, this.tsUtils.isArray) && + this.tsUtils.isOrDerivedFrom(rhsType, this.tsUtils.isArray) && + lhsType !== rhsType + ) + ) { + return; + } + + const rhsTypeStr = this.tsTypeChecker.typeToString(rhsType); + let lhsTypeStr = this.tsTypeChecker.typeToString(lhsType); + if (rhsExpr && (this.isNullOrEmptyArray(rhsExpr) || ts.isArrayLiteralExpression(rhsExpr))) { + return; + } + + if (ts.isAsExpression(node) && ts.isArrayLiteralExpression(node.expression)) { + node.expression.elements.forEach((elem) => { + if (elem.kind === ts.SyntaxKind.FalseKeyword || elem.kind === ts.SyntaxKind.TrueKeyword) { + lhsTypeStr = rhsTypeStr.replace(elem.getText(), 'boolean'); + } + }); + } + if (lhsTypeStr !== rhsTypeStr) { + this.incrementCounters(node, FaultID.ArrayTypeImmutable); + } + } + + private isNullOrEmptyArray(expr: ts.Expression): boolean { + if (ts.isNewExpression(expr)) { + const constructorSym = this.tsTypeChecker.getSymbolAtLocation(expr.expression); + if (constructorSym?.name === 'Array') { + if (!expr.arguments || expr.arguments.length === 0) { + return true; + } + if (expr.arguments.length === 1) { + const argType = this.tsTypeChecker.getTypeAtLocation(expr.arguments[0]); + return !!(argType.flags & ts.TypeFlags.NumberLike); + } + } + } + + return false; + } + private handleExponentOperation(node: ts.Node): void { if (!this.options.arkts2) { return; @@ -6467,6 +6635,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { !ts.isNonNullExpression(node) || !ts.isNonNullExpression(node.expression) || ts.isNonNullExpression(node.parent) || + ts.isPropertyAccessExpression(node.parent) || ts.isNonNullExpression(node.expression.expression) ) { return; @@ -6474,26 +6643,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const statement = ts.findAncestor(node, ts.isExpressionStatement); if (statement && this.isCustomComponent(statement)) { - let currentParam: ts.Identifier | undefined; - if (ts.isPropertyAccessExpression(node.expression.expression)) { - currentParam = node.expression.expression.name as ts.Identifier; - } - - let customParam: ts.Identifier | undefined; - if (ts.isPropertyAssignment(node.parent)) { - customParam = node.parent.name as ts.Identifier; - } - - if (!currentParam || !customParam) { - return; - } - - const originalExpr = node.parent.parent; - if (!ts.isObjectLiteralExpression(originalExpr)) { - return; - } - const autofix = this.autofixer?.fixCustomBidirectionalBinding(originalExpr, currentParam, customParam); - this.incrementCounters(node, FaultID.DoubleExclaBindingNotSupported, autofix); + this.handleCustomBidirectionalBinding(node, node.expression); } else { const autofix = this.autofixer?.fixNativeBidirectionalBinding(node, this.interfacesNeedToImport); this.incrementCounters(node, FaultID.DoubleExclaBindingNotSupported, autofix); @@ -6522,6 +6672,30 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return this.interfacesAlreadyImported.has(callExpr.expression.getText()); } + private handleCustomBidirectionalBinding(firstExpr: ts.NonNullExpression, secondExpr: ts.NonNullExpression): void { + let currentParam: ts.Identifier | undefined; + if (ts.isPropertyAccessExpression(secondExpr.expression)) { + currentParam = secondExpr.expression.name as ts.Identifier; + } + + let customParam: ts.Identifier | undefined; + if (ts.isPropertyAssignment(firstExpr.parent)) { + customParam = firstExpr.parent.name as ts.Identifier; + } + + if (!currentParam || !customParam) { + return; + } + + const originalExpr = firstExpr.parent.parent; + if (!ts.isObjectLiteralExpression(originalExpr)) { + return; + } + + const autofix = this.autofixer?.fixCustomBidirectionalBinding(originalExpr, currentParam, customParam); + this.incrementCounters(firstExpr, FaultID.DoubleExclaBindingNotSupported, autofix); + } + private handleDoubleDollar(node: ts.Node): void { if (!this.options.arkts2) { return; @@ -6764,8 +6938,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (parent.right.text !== node.text) { return; } - this.checkAsonUsage(parent.left); - + if (ts.isQualifiedName(parent.parent) && ASON_WHITE_SET.has(parent.parent.right.text)) { + this.checkAsonUsage(parent.left, true); + } else { + this.checkAsonUsage(parent.left, false); + } break; case ts.SyntaxKind.PropertyAccessExpression: if (!ts.isPropertyAccessExpression(parent)) { @@ -6774,20 +6951,26 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (parent.name.text !== node.text) { return; } - this.checkAsonUsage(parent.expression); - + if (ts.isPropertyAccessExpression(parent.parent) && ASON_WHITE_SET.has(parent.parent.name.text)) { + this.checkAsonUsage(parent.expression, true); + } else { + this.checkAsonUsage(parent.expression, false); + } break; default: } } - private checkAsonUsage(nodeToCheck: ts.Node): void { + private checkAsonUsage(nodeToCheck: ts.Node, needAutofix: boolean): void { if (!ts.isIdentifier(nodeToCheck)) { return; } + const declaration = this.tsUtils.getDeclarationNode(nodeToCheck); if (!declaration && nodeToCheck.text === ARKTS_UTILS_TEXT) { - this.incrementCounters(nodeToCheck, FaultID.LimitedStdLibNoASON); + const autofix = + needAutofix && this.autofixer ? this.autofixer.replaceNode(nodeToCheck.parent, JSON_TEXT) : undefined; + this.incrementCounters(nodeToCheck, FaultID.LimitedStdLibNoASON, autofix); return; } @@ -6803,7 +6986,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return fileName.startsWith(moduleName); }) ) { - this.incrementCounters(nodeToCheck, FaultID.LimitedStdLibNoASON); + const autofix = + needAutofix && this.autofixer ? this.autofixer.replaceNode(nodeToCheck.parent, JSON_TEXT) : undefined; + this.incrementCounters(nodeToCheck, FaultID.LimitedStdLibNoASON, autofix); } } @@ -6950,7 +7135,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); this.interfacesNeedToAlarm.forEach((identifier) => { - this.incrementCounters(identifier, FaultID.UIInterfaceImport, autofix); + const name = identifier.getText(); + const errorMsg = `The ArkUI interface "${name}" should be imported before it is used (arkui-modular-interface)`; + this.incrementCounters(identifier, FaultID.UIInterfaceImport, autofix, errorMsg); }); this.interfacesNeedToAlarm = []; @@ -7286,7 +7473,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - if (!TypeScriptLinter.isDeclaredInArkTs2(callSignature)) { + if (!this.isDeclaredInArkTs2(callSignature)) { return; } @@ -7388,21 +7575,49 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node) || ts.isFunctionExpression(node); } - private handleSdkForConstructorFuncs(node: ts.PropertyAccessExpression): void { - if (!this.options.arkts2 || !node) { - return; + private static isThirdPartyBySymbol(symbol: ts.Symbol | undefined, apiList: ApiListItem): boolean { + if (!symbol) { + return false; } - const sdkInfos = this.interfaceMap.get(node.expression.getText()); - if (!sdkInfos || sdkInfos.size === 0) { - return; + const declaration = symbol.getDeclarations()?.[0]; + if (declaration && ts.isImportClause(declaration)) { + const importDecl = declaration.parent; + const importPath = TsUtils.removeOrReplaceQuotes(importDecl.moduleSpecifier.getText(), false); + const import_path = TypeScriptLinter.getLocalApiListItemByKey(SdkNameInfo.ImportPath, apiList); + if (import_path.includes(importPath)) { + return true; + } } + return false; + } - for (const sdkInfo of sdkInfos) { - const propertyName = node.name.getText(); - if (propertyName === sdkInfo.api_name) { - this.incrementCounters(node.name, FaultID.ConstructorTypesDeprecated); - } + private static getLocalApiListItemByKey(key: string, apiList: ApiListItem): string | string[] { + if (!apiList) { + return ''; } + if (SdkNameInfo.ImportPath === key) { + return apiList.import_path; + } + return ''; + } + + private handleSdkForConstructorFuncs(node: ts.PropertyAccessExpression | ts.QualifiedName): void { + if (!this.options.arkts2) { + return; + } + const rightNode = ts.isPropertyAccessExpression(node) ? node.name : node.right; + const leftNode = ts.isPropertyAccessExpression(node) ? node.expression : node.left; + const constructorFuncsInfos = Array.from(TypeScriptLinter.constructorFuncsSet); + constructorFuncsInfos.some((constructorFuncsInfo) => { + const api_name = constructorFuncsInfo.api_info.api_name; + if (api_name !== rightNode.getText()) { + return; + } + const parentSym = this.tsTypeChecker.getSymbolAtLocation(leftNode); + if (TypeScriptLinter.isThirdPartyBySymbol(parentSym, constructorFuncsInfo)) { + this.incrementCounters(rightNode, FaultID.ConstructorTypesDeprecated); + } + }); } private handleQuotedHyphenPropsDeprecated(node: ts.PropertyAccessExpression | ts.PropertyAssignment): void { @@ -7450,7 +7665,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } if (ts.isPropertySignature(node)) { - return this.tsTypeChecker.getTypeAtLocation(node.type!).getSymbol(); + return this.tsTypeChecker.getSymbolAtLocation(node); } const nodesWithResolvableType = [ @@ -7488,38 +7703,27 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isTypeReferenceNode(typeNode)) { return undefined; } - const symbol = this.tsTypeChecker.getTypeAtLocation(typeNode).getSymbol(); - if (!symbol) { - return this.resolveTypeNoSymbol(typeNode); - } - const declarations = symbol.getDeclarations(); - if (declarations && declarations.length > 0) { - const declaration = declarations[0]; - if (ts.isTypeAliasDeclaration(declaration)) { - return this.resolveTypeNodeSymbol(declaration.type); - } else if (ts.isInterfaceDeclaration(declaration)) { - const heritageSymbol = this.processQuotedHyphenPropsDeprecatedOnInterfaceDeclaration(declaration); - return heritageSymbol; - } - } - return this.tsTypeChecker.getTypeAtLocation(typeNode).getSymbol(); + return this.resolveTypeNoSymbol(typeNode); } private resolveTypeNoSymbol(typeNode: ts.TypeReferenceNode): ts.Symbol | undefined { if (!typeNode.typeName) { return undefined; } + if (ts.isQualifiedName(typeNode.typeName)) { return this.tsTypeChecker.getSymbolAtLocation(typeNode.typeName.right); } - const sym = this.tsUtils.trueSymbolAtLocation(typeNode.typeName); - if (sym) { - const globalDeclaration = sym.getDeclarations()?.[0]; - if (globalDeclaration && ts.isTypeAliasDeclaration(globalDeclaration)) { + + const symbol = this.tsUtils.trueSymbolAtLocation(typeNode.typeName); + if (symbol?.declarations && symbol.declarations.length > 0) { + const globalDeclaration = symbol.declarations[0]; + if (ts.isTypeAliasDeclaration(globalDeclaration)) { return this.resolveTypeNodeSymbol(globalDeclaration.type); + } else if (ts.isInterfaceDeclaration(globalDeclaration)) { + return this.processQuotedHyphenPropsDeprecatedOnInterfaceDeclaration(globalDeclaration); } } - return this.tsTypeChecker.getTypeAtLocation(typeNode).getSymbol(); } @@ -7604,8 +7808,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return undefined; } - private processApiNodeSdkDuplicateDeclName(apiName: string, errorNode: ts.Node): void { - const setApiListItem = TypeScriptLinter.globalApiInfo.get(SdkProblem.DeclWithDuplicateName); + private processApiNodeSdkGlobalApi(apiName: string, errorNode: ts.Node): void { + for (const [key, value] of globalApiAssociatedInfo) { + this.doProcessApiNodeSdkGlobalApi(apiName, errorNode, key, value); + } + } + + private doProcessApiNodeSdkGlobalApi(apiName: string, errorNode: ts.Node, key: string, faultId: number): void { + const setApiListItem = TypeScriptLinter.globalApiInfo.get(key); if (!setApiListItem) { return; } @@ -7628,11 +7838,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { }); if (matchedApi) { - this.incrementCounters(errorNode, FaultID.DuplicateDeclNameFromSdk); + this.incrementCounters(errorNode, faultId); } } - private handleSdkDuplicateDeclName( + private handleSdkGlobalApi( node: | ts.TypeReferenceNode | ts.NewExpression @@ -7643,75 +7853,86 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { | ts.BinaryExpression | ts.ExpressionWithTypeArguments | ts.Identifier + | ts.MethodDeclaration ): void { if (!this.options.arkts2) { return; } switch (node.kind) { case ts.SyntaxKind.TypeReference: - this.checkTypeReferenceForSdkDuplicateDeclName(node); + this.checkTypeReferenceForSdkGlobalApi(node); break; case ts.SyntaxKind.NewExpression: - this.checkNewExpressionForSdkDuplicateDeclName(node); + this.checkNewExpressionForSdkGlobalApi(node); break; case ts.SyntaxKind.Identifier: - this.checkHeritageClauseForSdkDuplicateDeclName(node); + this.checkHeritageClauseForSdkGlobalApi(node); break; case ts.SyntaxKind.VariableDeclaration: case ts.SyntaxKind.PropertyDeclaration: case ts.SyntaxKind.Parameter: - this.checkDeclarationForSdkDuplicateDeclName(node); + this.checkDeclarationForSdkGlobalApi(node); break; case ts.SyntaxKind.CallExpression: - this.checkCallExpressionForSdkDuplicateDeclName(node); + this.checkCallExpressionForSdkGlobalApi(node); break; case ts.SyntaxKind.BinaryExpression: - this.checkBinaryExpressionForSdkDuplicateDeclName(node); + this.checkBinaryExpressionForSdkGlobalApi(node); + break; + case ts.SyntaxKind.MethodDeclaration: + this.checkMethodDeclarationForSdkGlobalApi(node); break; default: } } - private checkTypeReferenceForSdkDuplicateDeclName(node: ts.TypeReferenceNode): void { + private checkTypeReferenceForSdkGlobalApi(node: ts.TypeReferenceNode): void { const typeName = node.typeName; if (ts.isIdentifier(typeName)) { - this.processApiNodeSdkDuplicateDeclName(typeName.text, node); + this.processApiNodeSdkGlobalApi(typeName.text, node); } } - private checkNewExpressionForSdkDuplicateDeclName(node: ts.NewExpression): void { + private checkNewExpressionForSdkGlobalApi(node: ts.NewExpression): void { const expression = node.expression; if (ts.isIdentifier(expression)) { - this.processApiNodeSdkDuplicateDeclName(expression.text, expression); + this.processApiNodeSdkGlobalApi(expression.text, expression); } } - private checkHeritageClauseForSdkDuplicateDeclName(node: ts.Identifier): void { + private checkHeritageClauseForSdkGlobalApi(node: ts.Identifier): void { if (ts.isIdentifier(node)) { - this.processApiNodeSdkDuplicateDeclName(node.text, node); + this.processApiNodeSdkGlobalApi(node.text, node); } } - private checkDeclarationForSdkDuplicateDeclName( + private checkDeclarationForSdkGlobalApi( node: ts.VariableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration ): void { const expression = node.initializer; if (expression && ts.isIdentifier(expression)) { - this.processApiNodeSdkDuplicateDeclName(expression.text, expression); + this.processApiNodeSdkGlobalApi(expression.text, expression); } } - private checkCallExpressionForSdkDuplicateDeclName(node: ts.CallExpression): void { + private checkCallExpressionForSdkGlobalApi(node: ts.CallExpression): void { if (ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.expression)) { const expression = node.expression.expression; - this.processApiNodeSdkDuplicateDeclName(expression.text, expression); + this.processApiNodeSdkGlobalApi(expression.text, expression); } } - private checkBinaryExpressionForSdkDuplicateDeclName(node: ts.BinaryExpression): void { + private checkBinaryExpressionForSdkGlobalApi(node: ts.BinaryExpression): void { const expression = node.right; if (ts.isIdentifier(expression)) { - this.processApiNodeSdkDuplicateDeclName(expression.text, expression); + this.processApiNodeSdkGlobalApi(expression.text, expression); + } + } + + private checkMethodDeclarationForSdkGlobalApi(node: ts.MethodDeclaration): void { + const expression = node.name; + if (ts.isIdentifier(expression)) { + this.processApiNodeSdkGlobalApi(expression.text, expression); } } @@ -7721,9 +7942,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } if (node.token === ts.SyntaxKind.ExtendsKeyword || node.token === ts.SyntaxKind.ImplementsKeyword) { node.types.forEach((type) => { + this.handleSharedArrayBuffer(type); const expr = type.expression; if (ts.isIdentifier(expr)) { - this.processApiNodeSdkDuplicateDeclName(expr.text, expr); + this.processApiNodeSdkGlobalApi(expr.text, expr); } }); } @@ -7890,7 +8112,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private fixJsImportCallExpression(callExpr: ts.CallExpression): void { - if (!this.options.arkts2 || !this.useStatic) { + if ( + !this.options.arkts2 || + !this.useStatic || + ts.isAwaitExpression(callExpr.parent) || + ts.isTypeOfExpression(callExpr.parent) + ) { return; } @@ -7956,34 +8183,25 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } // Try direct check first - if (this.tsUtils.isImportedFromJS(identifier)) { - const autofix = this.autofixer?.createReplacementForJsImportPropertyAccessExpression( - node as ts.PropertyAccessExpression - ); - - this.incrementCounters( - node, - TsUtils.isInsideIfCondition(node) ? FaultID.InteropJsObjectConditionJudgment : FaultID.InteropJsObjectUsage, - autofix - ); + if (!this.tsUtils.isImportedFromJS(identifier)) { return; } - - // Try indirect reference (e.g., const foo = importedObj;) - const originalIdentifier = this.tsUtils.findOriginalIdentifier(identifier); - if (originalIdentifier && this.tsUtils.isImportedFromJS(originalIdentifier)) { - const autofix = this.autofixer?.createReplacementForJsIndirectImportPropertyAccessExpression( - node as ts.PropertyAccessExpression - ); - this.incrementCounters(node, FaultID.InteropJsObjectUsage, autofix); + const autofix = this.autofixer?.createReplacementForJsImportPropertyAccessExpression( + node as ts.PropertyAccessExpression + ); + if (!TsUtils.isInsideIfCondition(node)) { + return; } + this.incrementCounters(node, FaultID.InteropJsObjectConditionJudgment, autofix); } private fixJsImportElementAccessExpression(elementAccessExpr: ts.ElementAccessExpression): void { if (!this.options.arkts2 || !this.useStatic) { return; } - + if (!TypeScriptLinter.isInForLoopBody(elementAccessExpr)) { + return; + } const variableDeclaration = ts.isIdentifier(elementAccessExpr.expression) ? this.tsUtils.findVariableDeclaration(elementAccessExpr.expression) : undefined; @@ -8002,58 +8220,54 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - const autofix = this.autofixer?.createReplacementJsImportElementAccessExpression( - elementAccessExpr, - elementAccessExpr.expression as ts.Identifier - ); + const autofix = this.autofixer?.fixJsImportElementAccessExpression(elementAccessExpr); this.incrementCounters(elementAccessExpr, FaultID.InteropJsObjectTraverseJsInstance, autofix); } - private handleTaskPoolDeprecatedUsages(node: ts.CallExpression): void { - if (!this.options.arkts2 || !this.useStatic) { - return; + private static isInForLoopBody(node: ts.Node): boolean { + let current: ts.Node | undefined = node.parent; + while (current) { + if (ts.isForStatement(current) || ts.isForInStatement(current) || ts.isForOfStatement(current)) { + return true; + } + current = current.parent; } + return false; + } - if (!ts.isPropertyAccessExpression(node.expression)) { + private handleTaskPoolDeprecatedUsages(propertyAccess: ts.PropertyAccessExpression): void { + if (!this.options.arkts2 || !this.useStatic) { return; } - - const propertyAccess = node.expression; - const objectExpr = propertyAccess.expression; - + const objectExpr = ts.isNewExpression(propertyAccess.expression) ? + propertyAccess.expression.expression : + propertyAccess.expression; // Step 1: Must be either setCloneList or setTransferList if (!TypeScriptLinter.isDeprecatedTaskPoolMethodCall(propertyAccess)) { return; } - - if (!ts.isIdentifier(objectExpr)) { + const variableDecl = TsUtils.getDeclaration(this.tsUtils.trueSymbolAtLocation(objectExpr)); + const isNoContinue = + !variableDecl || + !ts.isVariableDeclaration(variableDecl) || + !variableDecl?.initializer || + !ts.isNewExpression(variableDecl.initializer); + if (isNoContinue) { return; } - - // Step 2: Resolve declaration of task - const variableDecl = this.tsUtils.findVariableDeclaration(objectExpr); - if (!variableDecl?.initializer || !ts.isNewExpression(variableDecl.initializer)) { - return; - } - - // Step 3: Check new taskpool.Task() const taskpoolExpr = variableDecl.initializer.expression; - if (!TypeScriptLinter.isTaskPoolTaskCreation(taskpoolExpr)) { + if (!this.isTaskPoolTaskCreation(taskpoolExpr)) { return; } - const faultId = propertyAccess.name.text === DEPRECATED_TASKPOOL_METHOD_SETCLONELIST ? FaultID.SetCloneListDeprecated : FaultID.SetTransferListDeprecated; - this.incrementCounters(node.parent, faultId); + this.incrementCounters(propertyAccess.name, faultId); } private static isDeprecatedTaskPoolMethodCall(propertyAccess: ts.PropertyAccessExpression): boolean { - if (!ts.isIdentifier(propertyAccess.expression)) { - return false; - } const methodName = propertyAccess.name.text; return ( methodName === DEPRECATED_TASKPOOL_METHOD_SETCLONELIST || @@ -8061,13 +8275,83 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); } - private static isTaskPoolTaskCreation(taskpoolExpr: ts.Expression): boolean { - return ( - ts.isPropertyAccessExpression(taskpoolExpr) && - ts.isIdentifier(taskpoolExpr.expression) && - taskpoolExpr.expression.text === STDLIB_TASKPOOL_OBJECT_NAME && - taskpoolExpr.name.text === STDLIB_TASK_CLASS_NAME - ); + private isTaskPoolTaskCreation(taskpoolExpr: ts.Expression): boolean { + if ( + ts.isIdentifier(taskpoolExpr) || + ts.isPropertyAccessExpression(taskpoolExpr) && taskpoolExpr.name.text === STDLIB_TASK_CLASS_NAME + ) { + const objectExpr = ts.isIdentifier(taskpoolExpr) ? taskpoolExpr : taskpoolExpr.expression; + return this.isTaskPoolReferenceisTaskPoolImportForTaskPoolDeprecatedUsages(objectExpr); + } + return false; + } + + private isTaskPoolReferenceisTaskPoolImportForTaskPoolDeprecatedUsages(expr: ts.Expression): boolean { + if (ts.isIdentifier(expr)) { + const sym = this.tsTypeChecker.getSymbolAtLocation(expr); + const importChild = TsUtils.getDeclaration(sym); + if (!importChild) { + return false; + } + if (ts.isImportSpecifier(importChild)) { + return TypeScriptLinter.isTaskPoolImportForTaskPoolDeprecatedUsages(importChild); + } + if (ts.isImportClause(importChild) && importChild.name?.text === STDLIB_TASKPOOL_OBJECT_NAME) { + return TypeScriptLinter.checkModuleSpecifierForTaskPoolDeprecatedUsages(importChild.parent); + } + } + if (ts.isPropertyAccessExpression(expr)) { + return this.isTaskPoolReferenceOnPropertyAccessExpression(expr); + } + return false; + } + + private static checkModuleSpecifierForTaskPoolDeprecatedUsages(importDecl: ts.ImportDeclaration): boolean { + if (ts.isImportDeclaration(importDecl) && ts.isStringLiteral(importDecl.moduleSpecifier)) { + const moduleSpecifier = importDecl.moduleSpecifier; + return TASKPOOL_MODULES.includes(TsUtils.removeOrReplaceQuotes(moduleSpecifier.getText(), false)); + } + return false; + } + + private isTaskPoolReferenceOnPropertyAccessExpression(expr: ts.PropertyAccessExpression): boolean { + if (expr.name.text !== STDLIB_TASKPOOL_OBJECT_NAME || !ts.isIdentifier(expr.expression)) { + return false; + } + const sym = this.tsTypeChecker.getSymbolAtLocation(expr.expression); + const importChild = TsUtils.getDeclaration(sym); + if (importChild && ts.isNamespaceImport(importChild)) { + return TypeScriptLinter.checkModuleSpecifierForTaskPoolDeprecatedUsages(importChild.parent.parent); + } + return false; + } + + private static isTaskPoolImportForTaskPoolDeprecatedUsages(specifier: ts.ImportSpecifier): boolean { + const specifierName = specifier.propertyName ? specifier.propertyName : specifier.name; + if (STDLIB_TASKPOOL_OBJECT_NAME !== specifierName.text) { + return false; + } + const importDeclaration = specifier.parent.parent.parent; + return TypeScriptLinter.checkModuleSpecifierForTaskPoolDeprecatedUsages(importDeclaration); + } + + private handleForOfJsArray(node: ts.ForOfStatement): void { + if (!this.options.arkts2 || !this.useStatic) { + return; + } + + const expr = node.expression; + if (!ts.isIdentifier(expr) || !this.tsUtils.isPossiblyImportedFromJS(expr)) { + return; + } + + const exprType = this.tsTypeChecker.getTypeAtLocation(expr); + + if (!this.tsUtils.isArray(exprType)) { + return; + } + + this.incrementCounters(node, FaultID.InteropJsObjectTraverseJsInstance); } private checkStdLibConcurrencyImport(importDeclaration: ts.ImportDeclaration): void { @@ -8242,7 +8526,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { defaultSymbol = this.tsUtils.trueSymbolAtLocation(importClause.name); } if (namedBindings) { - if (ts.isNamedImports(namedBindings)) { + if (ts.isNamedImports(namedBindings) && namedBindings.elements?.length > 0 && namedBindings.elements[0]?.name) { symbol = this.tsUtils.trueSymbolAtLocation(namedBindings.elements[0].name); } else if (ts.isNamespaceImport(namedBindings)) { symbol = this.tsUtils.trueSymbolAtLocation(namedBindings.name); @@ -8301,27 +8585,41 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.options.arkts2 || !this.useStatic) { return; } + const left = node.left; const right = node.right; const getNode = (expr: ts.Expression): ts.Node => { return ts.isPropertyAccessExpression(expr) || ts.isCallExpression(expr) ? expr.expression : expr; }; + const leftExpr = getNode(left); const rightExpr = getNode(right); - if (this.tsUtils.isJsImport(leftExpr) || this.tsUtils.isJsImport(rightExpr)) { - this.incrementCounters(node, FaultID.InteropJsInstanceof); + + if (!this.tsUtils.isJsImport(leftExpr) && !this.tsUtils.isJsImport(rightExpr)) { + return; } + + const autofix = this.autofixer?.fixInteropJsInstanceOfExpression(node); + this.incrementCounters(node, FaultID.InteropJsInstanceof, autofix); } private checkAutoIncrementDecrement(unaryExpr: ts.PostfixUnaryExpression | ts.PrefixUnaryExpression): void { - if (ts.isPropertyAccessExpression(unaryExpr.operand)) { - const propertyAccess = unaryExpr.operand; - if (this.useStatic && this.options.arkts2) { - if (this.isFromJSModule(propertyAccess.expression)) { - this.incrementCounters(unaryExpr, FaultID.InteropIncrementDecrement); - } - } + if (!this.useStatic || !this.options.arkts2) { + return; } + + if (!ts.isPropertyAccessExpression(unaryExpr.operand)) { + return; + } + + const propertyAccess = unaryExpr.operand; + if (!this.tsUtils.isJsImport(propertyAccess.expression)) { + return; + } + + const autofix = this.autofixer?.fixUnaryIncrDecr(unaryExpr, propertyAccess); + + this.incrementCounters(unaryExpr, FaultID.InteropIncrementDecrement, autofix); } private handleObjectLiteralforUnionTypeInterop(node: ts.VariableDeclaration): void { @@ -8349,7 +8647,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } for (const declaration of symbol.declarations ?? []) { - if (!TsUtils.isArkts12File(declaration.getSourceFile())) { + if (!this.tsUtils.isArkts12File(declaration.getSourceFile())) { return true; } } @@ -8414,7 +8712,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const isFromArkTs2 = declarations.some((decl) => { - return TsUtils.isArkts12File(decl.getSourceFile()); + return this.tsUtils.isArkts12File(decl.getSourceFile()); }); if (isFromArkTs2) { @@ -8551,17 +8849,17 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } - return TypeScriptLinter.isTypeFromArkts12(type); + return this.isTypeFromArkts12(type); } - private static isTypeFromArkts12(type: ts.Type): boolean { + private isTypeFromArkts12(type: ts.Type): boolean { const symbol = type?.getSymbol(); if (!symbol) { return false; } const isFromArkts12 = (symbol.declarations ?? []).some((decl) => { - return TsUtils.isArkts12File(decl.getSourceFile()); + return this.tsUtils.isArkts12File(decl.getSourceFile()); }); if (isFromArkts12) { @@ -8607,13 +8905,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const propType = this.tsTypeChecker.getTypeOfSymbolAtLocation(property, property.valueDeclaration); - if (TypeScriptLinter.isTypeFromArkts12(propType)) { + if (this.isTypeFromArkts12(propType)) { this.incrementCounters(prop.initializer, FaultID.InteropStaticObjectLiterals); } } private handleObjectLiteralAssignment(node: ts.VariableDeclaration): void { - if (TsUtils.isArkts12File(node.getSourceFile())) { + if (this.tsUtils.isArkts12File(node.getSourceFile())) { return; } @@ -8637,7 +8935,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private handleObjectLiteralInFunctionArgs(node: ts.CallExpression): void { - if (TsUtils.isArkts12File(node.getSourceFile())) { + if (this.tsUtils.isArkts12File(node.getSourceFile())) { return; } const signature = this.tsTypeChecker.getResolvedSignature(node); @@ -8660,7 +8958,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const paramType = this.tsTypeChecker.getTypeOfSymbolAtLocation(param, param.valueDeclaration); - if (TypeScriptLinter.isTypeFromArkts12(paramType)) { + if (this.isTypeFromArkts12(paramType)) { this.incrementCounters(arg, FaultID.InteropStaticObjectLiterals); } } else if (this.isObjectLiteralAssignedToArkts12Type(arg)) { @@ -8670,7 +8968,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } private handleObjectLiteralInReturn(node: ts.ReturnStatement): void { - if (TsUtils.isArkts12File(node.getSourceFile())) { + if (this.tsUtils.isArkts12File(node.getSourceFile())) { return; } @@ -8696,7 +8994,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (functionNode?.type) { const returnType = this.tsTypeChecker.getTypeAtLocation(functionNode.type); - if (TypeScriptLinter.isTypeFromArkts12(returnType)) { + if (this.isTypeFromArkts12(returnType)) { this.incrementCounters(node.expression, FaultID.InteropStaticObjectLiterals); } } else if (this.isObjectLiteralAssignedToArkts12Type(node.expression)) { @@ -8723,23 +9021,32 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - if (!ts.isIdentifier(node.expression) || !ts.isNumericLiteral(node.argumentExpression)) { - return; - } - const symbol = this.tsUtils.trueSymbolAtLocation(node.expression); if (!symbol?.declarations) { return; } for (const decl of symbol.declarations) { - if (ts.isEnumDeclaration(decl)) { + if (ts.isEnumDeclaration(decl) && this.shouldIncrementCounters(node)) { this.incrementCounters(node, FaultID.UnsupportPropNameFromValue); return; } } } + private shouldIncrementCounters(node: ts.ElementAccessExpression): boolean { + const indexExpr = node.argumentExpression; + if (!indexExpr) { + return false; + } + if (ts.isStringLiteral(indexExpr) || ts.isNumericLiteral(indexExpr)) { + return true; + } + const type = this.tsTypeChecker.getTypeAtLocation(indexExpr); + const typeString = this.tsTypeChecker.typeToString(type); + return typeString === 'number' || typeString === 'string'; + } + private handleMakeObserved(node: ts.PropertyAccessExpression): void { if (!this.options.arkts2) { return; @@ -8794,15 +9101,16 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } + const autofix = this.autofixer?.fixPropDecorator(decorators[0], decoratorName); switch (decoratorName) { case PropDecoratorName.Prop: - this.incrementCounters(node, FaultID.PropDecoratorNotSupported); + this.incrementCounters(node, FaultID.PropDecoratorNotSupported, autofix); break; case PropDecoratorName.StorageProp: - this.incrementCounters(node, FaultID.StoragePropDecoratorNotSupported); + this.incrementCounters(node, FaultID.StoragePropDecoratorNotSupported, autofix); break; case PropDecoratorName.LocalStorageProp: - this.incrementCounters(node, FaultID.LocalStoragePropDecoratorNotSupported); + this.incrementCounters(node, FaultID.LocalStoragePropDecoratorNotSupported, autofix); break; default: } @@ -8872,101 +9180,255 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return targetTypes.includes(storageType.getText()); } - private handleAwaitExpression(node: ts.Node): void { - if (!this.options.arkts2 || !this.useStatic) { + private handlePropertyAssignmentForProp(node: ts.PropertyAssignment): void { + if (!this.options.arkts2) { return; } - const awaitExpr = node as ts.AwaitExpression; - const checkAndReportJsImportAwait = (targetNode: ts.Node): boolean => { - if (ts.isIdentifier(targetNode) && this.tsUtils.isJsImport(targetNode)) { - this.incrementCounters(node, FaultID.NoAwaitJsPromise); - return true; + + const callExpr = node.parent.parent; + if (!ts.isCallExpression(callExpr)) { + return; + } + + const structDecl = TsUtils.getDeclaration(this.tsTypeChecker.getSymbolAtLocation(callExpr.expression)); + if (!structDecl || !ts.isStructDeclaration(structDecl) || !structDecl.name) { + return; + } + + const variable = node.name; + if (!ts.isIdentifier(variable)) { + return; + } + + const targetNode = TypeScriptLinter.findVariableChangeNodeInStruct(variable, structDecl); + if (!targetNode) { + return; + } + + const targetDecl = TsUtils.getDeclaration(this.tsTypeChecker.getSymbolAtLocation(targetNode)); + if (!targetDecl || !ts.isPropertyDeclaration(targetDecl)) { + return; + } + + const decorators = ts.getDecorators(targetDecl); + if (!decorators || decorators.length === 0) { + return; + } + + const decorator = decorators[0]; + const decoratorName = TsUtils.getDecoratorName(decorator); + if (decoratorName === PropDecoratorName.Prop) { + this.incrementCounters(node, FaultID.PropNeedCallMethodForDeepCopy); + } + } + + private static findVariableChangeNodeInStruct( + variable: ts.Identifier, + structDecl: ts.StructDeclaration + ): ts.MemberName | undefined { + let changeNode: ts.MemberName | undefined; + + function traverse(node: ts.Node): void { + if (changeNode) { + return; } - return false; - }; + + if (ts.isPropertyAccessExpression(node)) { + if ( + node.expression.kind === ts.SyntaxKind.ThisKeyword && + node.name.getText() === variable.getText() && + (ts.findAncestor(node, ts.isPostfixUnaryExpression) || + ts.findAncestor(node, ts.isPrefixUnaryExpression) || + ts.findAncestor(node, ts.isBinaryExpression)) + ) { + changeNode = node.name; + } + } + + ts.forEachChild(node, traverse); + } + + traverse(structDecl); + return changeNode; + } + + private getIdentifierForAwaitExpr(awaitExpr: ts.AwaitExpression): IdentifierAndArguments { + void this; + + let ident: undefined | ts.Identifier; + let args: ts.NodeArray | undefined; + const expr = awaitExpr.expression; - checkAndReportJsImportAwait(expr); if (ts.isCallExpression(expr)) { - checkAndReportJsImportAwait(expr.expression); + if (ts.isIdentifier(expr.expression)) { + ident = expr.expression; + } + + if (ts.isPropertyAccessExpression(expr.expression)) { + if (ts.isIdentifier(expr.expression.name)) { + ident = expr.expression.name; + } + } + args = expr.arguments; + } else if (ts.isIdentifier(expr)) { + ident = expr; } + + return { ident, args }; + } + + private handleAwaitExpression(awaitExpr: ts.AwaitExpression): void { + if (!this.options.arkts2 || !this.useStatic) { + return; + } + const { ident, args } = this.getIdentifierForAwaitExpr(awaitExpr); + if (!ident) { + return; + } + + if (!this.tsUtils.isJsImport(ident)) { + return; + } + + const declaration = this.tsUtils.getDeclarationNode(ident); + if (!declaration) { + return; + } + + if ( + ts.isFunctionDeclaration(declaration) && + TsUtils.hasModifier(declaration.modifiers, ts.SyntaxKind.AsyncKeyword) + ) { + const autofix = this.autofixer?.fixAwaitJsCallExpression(ident, args); + this.incrementCounters(awaitExpr, FaultID.NoAwaitJsPromise, autofix); + return; + } + + if (ts.isMethodDeclaration(declaration) && TsUtils.hasModifier(declaration.modifiers, ts.SyntaxKind.AsyncKeyword)) { + const autofix = this.autofixer?.fixAwaitJsMethodCallExpression(ident, args); + this.incrementCounters(awaitExpr, FaultID.NoAwaitJsPromise, autofix); + return; + } + + if (!ts.isVariableDeclaration(declaration)) { + return; + } + + const type = this.tsTypeChecker.getTypeAtLocation(declaration); + const typeString = this.tsTypeChecker.typeToString(type); + + if (typeString.split('<')[0] !== 'Promise') { + return; + } + + const autofix = this.autofixer?.fixAwaitJsPromise(ident); + this.incrementCounters(awaitExpr, FaultID.NoAwaitJsPromise, autofix); } private handleNotsLikeSmartType(classDecl: ts.ClassDeclaration): void { if (!this.options.arkts2) { return; } + const className = classDecl.name?.getText(); + const { staticProps, instanceProps } = this.collectClassProperties(classDecl); + classDecl.members.forEach((member) => { - if (ts.isMethodDeclaration(member)) { - this.checkMethod(member, className); + if (!ts.isMethodDeclaration(member) || !member.body) { + return; } + + const methodReturnType = this.tsTypeChecker.getTypeAtLocation(member); + this.checkMethodAndReturnStatements(member.body, className, methodReturnType, staticProps, instanceProps); }); } - private checkMethod(methodNode: ts.MethodDeclaration, className: string | undefined): void { - const variableDeclarations = new Map(); - const returnStatements: ts.ReturnStatement[] = []; - if (methodNode.body) { - ts.forEachChild(methodNode.body, (node) => { - this.visitMethodBody(node, variableDeclarations, returnStatements); - }); - } + private checkMethodAndReturnStatements( + body: ts.Block, + className: string | undefined, + methodReturnType: ts.Type, + staticProps: Map, + instanceProps: Map + ): void { + body.forEachChild((node) => { + if (!ts.isReturnStatement(node) || !node.expression) { + return; + } - const isStaticPropertyAccess = (node: ts.Expression, className: string): boolean => { - return ( - ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === className - ); - }; + const isStaticPropertyAccess = (node: ts.Expression, className: string): boolean => { + return ( + ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === className + ); + }; + const isInstancePropertyAccess = (node: ts.Expression): boolean => { + return ts.isPropertyAccessExpression(node) && node.expression.kind === ts.SyntaxKind.ThisKeyword; + }; - const isInstancePropertyAccess = (node: ts.Expression): boolean => { - return ts.isPropertyAccessExpression(node) && node.expression.kind === ts.SyntaxKind.ThisKeyword; - }; + if (className && isStaticPropertyAccess(node.expression, className)) { + this.checkPropertyAccess(node, node.expression as ts.PropertyAccessExpression, staticProps, methodReturnType); + return; + } - this.checkReturnStatements(returnStatements, className, isStaticPropertyAccess, isInstancePropertyAccess); + if (isInstancePropertyAccess(node.expression)) { + this.checkPropertyAccess(node, node.expression as ts.PropertyAccessExpression, instanceProps, methodReturnType); + } + }); } - private visitMethodBody( - node: ts.Node, - variableDeclarations: Map, - returnStatements: ts.ReturnStatement[] + private checkPropertyAccess( + returnNode: ts.ReturnStatement, + propAccess: ts.PropertyAccessExpression, + propsMap: Map, + methodReturnType: ts.Type ): void { - if (ts.isVariableStatement(node)) { - node.declarationList.declarations.forEach((decl) => { - if (ts.isIdentifier(decl.name)) { - variableDeclarations.set(decl.name.text, decl.type); - } - }); - } + const propName = propAccess.name.getText(); + const propType = propsMap.get(propName); - if (ts.isReturnStatement(node)) { - returnStatements.push(node); + if (propType && this.isExactlySameType(propType, methodReturnType)) { + return; } - ts.forEachChild(node, (child) => { - this.visitMethodBody(child, variableDeclarations, returnStatements); - }); + this.incrementCounters(returnNode, FaultID.NoTsLikeSmartType); } - private checkReturnStatements( - returnStatements: ts.ReturnStatement[], - className: string | undefined, - isStaticPropertyAccess: (node: ts.Expression, className: string) => boolean, - isInstancePropertyAccess: (node: ts.Expression) => boolean - ): void { - returnStatements.forEach((returnStmt) => { - if (!returnStmt.expression) { + private collectClassProperties(classDecl: ts.ClassDeclaration): { + staticProps: Map; + instanceProps: Map; + } { + const result = { + staticProps: new Map(), + instanceProps: new Map() + }; + + classDecl.members.forEach((member) => { + if (!ts.isPropertyDeclaration(member)) { return; } - const returnType = this.tsTypeChecker.getTypeAtLocation(returnStmt.expression); - if (className && isStaticPropertyAccess(returnStmt.expression, className) && returnType.isUnion()) { - this.incrementCounters(returnStmt, FaultID.NoTsLikeSmartType); - } + const propName = member.name.getText(); + const propType = this.tsTypeChecker.getTypeAtLocation(member); + const isStatic = member.modifiers?.some((m) => { + return m.kind === ts.SyntaxKind.StaticKeyword; + }); - if (isInstancePropertyAccess(returnStmt.expression) && returnType.isUnion()) { - this.incrementCounters(returnStmt, FaultID.NoTsLikeSmartType); + if (isStatic) { + result.staticProps.set(propName, propType); + } else { + result.instanceProps.set(propName, propType); } }); + + return result; + } + + private isExactlySameType(type1: ts.Type, type2: ts.Type): boolean { + if (type2.getCallSignatures().length > 0) { + const returnType = TsUtils.getFunctionReturnType(type2); + return returnType ? + this.tsTypeChecker.typeToString(type1) === this.tsTypeChecker.typeToString(returnType) : + false; + } + return this.tsTypeChecker.typeToString(type1) === this.tsTypeChecker.typeToString(type2); } private handleNumericBigintCompare(node: ts.BinaryExpression): void { @@ -8983,7 +9445,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return (type.flags & ts.TypeFlags.Number) !== 0 || (type.flags & ts.TypeFlags.NumberLiteral) !== 0; }; - const isBigIntAndNumberOperand = isNumber(leftType) && isBigInt(rightType) || isBigInt(leftType) && isNumber(rightType); + const isBigIntAndNumberOperand = + isNumber(leftType) && isBigInt(rightType) || isBigInt(leftType) && isNumber(rightType); if (isBigIntAndNumberOperand) { this.incrementCounters(node, FaultID.NumericBigintCompare); } @@ -9031,7 +9494,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (decorators) { for (const decorator of decorators) { const decoratorName = TsUtils.getDecoratorName(decorator); - if (decoratorName && decoratorName === CustomDecoratorName.Layoutable) { + if (decoratorName && decoratorName === CustomDecoratorName.CustomLayout) { return; } } @@ -9048,8 +9511,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const processExpression = (expr: ts.Expression): void => { const symbol = this.tsUtils.trueSymbolAtLocation(expr); - if (this.isJsFileSymbol(symbol)) { - this.incrementCounters(expr, FaultID.BinaryOperations); + if (this.isJsFileSymbol(symbol) || this.isJsFileExpression(expr)) { + const autofix = this.autofixer?.fixInteropOperators(expr); + this.incrementCounters(expr, FaultID.BinaryOperations, autofix); } }; @@ -9081,10 +9545,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return false; }; + const isStandardFloatFormat = (): boolean => { + const text = node.getText(); + return (/\.\d*0+$/).test(text); + }; const isNoNeedFix = isInElementAccessExpression(node) || - ts.isEnumMember(node.parent) || - 'name' in node.parent && node.parent.name === node; + 'name' in node.parent && node.parent.name === node || + isStandardFloatFormat(); if (isNoNeedFix) { return; } @@ -9097,4 +9565,390 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.NumericSemantics, autofix); } } + + private checkArrayUsageWithoutBound(accessExpr: ts.ElementAccessExpression): void { + if (!this.options.arkts2 || !this.useStatic) { + return; + } + + const arrayAccessInfo = this.getArrayAccessInfo(accessExpr); + if (!arrayAccessInfo) { + const accessArgument = accessExpr.argumentExpression; + if (TypeScriptLinter.isFunctionCall(accessArgument)) { + this.incrementCounters(accessExpr, FaultID.RuntimeArrayCheck); + } + return; + } + + const { arrayIdent } = arrayAccessInfo; + const arraySym = this.tsUtils.trueSymbolAtLocation(arrayIdent); + if (!arraySym) { + return; + } + + const indexExpr = accessExpr.argumentExpression; + const loopVarName = ts.isIdentifier(indexExpr) ? indexExpr.text : undefined; + + const { isInSafeContext, isValidBoundCheck, isVarModifiedBeforeAccess } = this.analyzeSafeContext( + accessExpr, + loopVarName, + arraySym + ); + + if (isInSafeContext) { + if (!isValidBoundCheck || isVarModifiedBeforeAccess) { + this.incrementCounters(arrayIdent.parent, FaultID.RuntimeArrayCheck); + } + } else { + this.incrementCounters(arrayIdent.parent, FaultID.RuntimeArrayCheck); + } + } + + private analyzeSafeContext( + accessExpr: ts.ElementAccessExpression, + loopVarName: string | undefined, + arraySym: ts.Symbol + ): { isInSafeContext: boolean; isValidBoundCheck: boolean; isVarModifiedBeforeAccess: boolean } { + const context = TypeScriptLinter.findSafeContext(accessExpr); + if (!context) { + return { isInSafeContext: false, isValidBoundCheck: false, isVarModifiedBeforeAccess: false }; + } + + return this.analyzeContextSafety(context, accessExpr, loopVarName, arraySym); + } + + static findSafeContext( + accessExpr: ts.ElementAccessExpression + ): { node: ts.ForStatement | ts.WhileStatement | ts.IfStatement } | void { + let currentNode: ts.Node | undefined = accessExpr; + + while (currentNode) { + if (ts.isForStatement(currentNode) || ts.isWhileStatement(currentNode) || ts.isIfStatement(currentNode)) { + return { node: currentNode }; + } + currentNode = currentNode.parent; + } + + return undefined; + } + + private analyzeContextSafety( + context: { node: ts.ForStatement | ts.WhileStatement | ts.IfStatement }, + accessExpr: ts.ElementAccessExpression, + loopVarName: string | undefined, + arraySym: ts.Symbol + ): { isInSafeContext: boolean; isValidBoundCheck: boolean; isVarModifiedBeforeAccess: boolean } { + const { node } = context; + + if (!loopVarName) { + return { + isInSafeContext: true, + isValidBoundCheck: false, + isVarModifiedBeforeAccess: false + }; + } + + const analysis = this.analyzeStatementType(node, accessExpr, loopVarName, arraySym); + + return { + isInSafeContext: true, + isValidBoundCheck: analysis.isValidBoundCheck, + isVarModifiedBeforeAccess: analysis.isVarModifiedBeforeAccess + }; + } + + private analyzeStatementType( + node: ts.ForStatement | ts.WhileStatement | ts.IfStatement, + accessExpr: ts.ElementAccessExpression, + loopVarName: string, + arraySym: ts.Symbol + ): { isValidBoundCheck: boolean; isVarModifiedBeforeAccess: boolean } { + switch (node.kind) { + case ts.SyntaxKind.ForStatement: + return this.analyzeForStatement(node, accessExpr, loopVarName, arraySym); + case ts.SyntaxKind.WhileStatement: + return this.analyzeWhileStatement(node, accessExpr, loopVarName, arraySym); + case ts.SyntaxKind.IfStatement: + return this.analyzeIfStatement(node, accessExpr, loopVarName, arraySym); + default: + return { isValidBoundCheck: false, isVarModifiedBeforeAccess: false }; + } + } + + private analyzeForStatement( + forNode: ts.ForStatement, + accessExpr: ts.ElementAccessExpression, + loopVarName: string, + arraySym: ts.Symbol + ): { isValidBoundCheck: boolean; isVarModifiedBeforeAccess: boolean } { + const isValidBoundCheck = forNode.condition ? + this.checkBoundCondition(forNode.condition, loopVarName, arraySym) : + false; + + const isVarModifiedBeforeAccess = forNode.statement ? + TypeScriptLinter.checkVarModifiedBeforeNode(forNode.statement, accessExpr, loopVarName) : + false; + + return { isValidBoundCheck, isVarModifiedBeforeAccess }; + } + + private analyzeWhileStatement( + whileNode: ts.WhileStatement, + accessExpr: ts.ElementAccessExpression, + loopVarName: string, + arraySym: ts.Symbol + ): { isValidBoundCheck: boolean; isVarModifiedBeforeAccess: boolean } { + const isValidBoundCheck = whileNode.expression ? + this.checkBoundCondition(whileNode.expression, loopVarName, arraySym) : + false; + + const isVarModifiedBeforeAccess = whileNode.statement ? + TypeScriptLinter.checkVarModifiedBeforeNode(whileNode.statement, accessExpr, loopVarName) : + false; + + return { isValidBoundCheck, isVarModifiedBeforeAccess }; + } + + private analyzeIfStatement( + ifNode: ts.IfStatement, + accessExpr: ts.ElementAccessExpression, + loopVarName: string, + arraySym: ts.Symbol + ): { isValidBoundCheck: boolean; isVarModifiedBeforeAccess: boolean } { + const isValidBoundCheck = ifNode.expression ? + this.checkBoundCondition(ifNode.expression, loopVarName, arraySym) : + false; + + let isVarModifiedBeforeAccess = false; + const statementBlock = ts.isBlock(ifNode.thenStatement) ? ifNode.thenStatement : undefined; + if (statementBlock) { + isVarModifiedBeforeAccess = TypeScriptLinter.checkVarModifiedBeforeNode(statementBlock, accessExpr, loopVarName); + } + + return { isValidBoundCheck, isVarModifiedBeforeAccess }; + } + + private checkBoundCondition(condition: ts.Expression, varName: string, arraySym: ts.Symbol): boolean { + if (ts.isBinaryExpression(condition)) { + const { left, right, operatorToken } = condition; + + if (this.checkVarLessThanArrayLength(left, right, operatorToken, varName, arraySym)) { + return true; + } + + if (this.checkArrayLengthGreaterThanVar(left, right, operatorToken, varName, arraySym)) { + return true; + } + + if (ts.isIdentifier(left) && left.text === varName && ts.isNumericLiteral(right)) { + const value = parseFloat(right.text); + if ( + operatorToken.kind === ts.SyntaxKind.GreaterThanEqualsToken && value <= 0 || + operatorToken.kind === ts.SyntaxKind.GreaterThanToken && value < 0 + ) { + return true; + } + } + + return this.checkBoundCondition(left, varName, arraySym) || this.checkBoundCondition(right, varName, arraySym); + } + + return false; + } + + private checkArrayLengthGreaterThanVar( + left: ts.Expression, + right: ts.Expression, + operatorToken: ts.Token, + varName: string, + arraySym: ts.Symbol + ): boolean { + if ( + ts.isPropertyAccessExpression(left) && + left.name.text === 'length' && + ts.isIdentifier(right) && + right.text === varName + ) { + const leftArraySym = this.tsUtils.trueSymbolAtLocation(left.expression); + if (leftArraySym === arraySym) { + return ( + operatorToken.kind === ts.SyntaxKind.GreaterThanToken || + operatorToken.kind === ts.SyntaxKind.GreaterThanEqualsToken + ); + } + } + return false; + } + + private checkVarLessThanArrayLength( + left: ts.Expression, + right: ts.Expression, + operatorToken: ts.Token, + varName: string, + arraySym: ts.Symbol + ): boolean { + return ( + ts.isIdentifier(left) && + left.text === varName && + ts.isPropertyAccessExpression(right) && + right.name.text === 'length' && + (operatorToken.kind === ts.SyntaxKind.LessThanToken || + operatorToken.kind === ts.SyntaxKind.LessThanEqualsToken) && + this.tsUtils.trueSymbolAtLocation(right.expression) === arraySym + ); + } + + private static traverseNodesUntilTarget( + node: ts.Node, + targetNode: ts.Node, + varName: string, + scopeStack: { shadowed: boolean; localVars: Set }[], + state: { targetFound: boolean; modified: boolean } + ): void { + if (node === targetNode) { + state.targetFound = true; + return; + } + + if (state.targetFound) { + return; + } + + const newScope = this.handleNewScope(node, scopeStack); + + TypeScriptLinter.getVariablesFromScope(node, varName, scopeStack); + + if (this.isVariableModified(node, varName, scopeStack)) { + state.modified = true; + } + + ts.forEachChild(node, (child) => { + this.traverseNodesUntilTarget(child, targetNode, varName, scopeStack, state); + }); + + if (newScope) { + scopeStack.pop(); + } + } + + private static handleNewScope( + node: ts.Node, + scopeStack: { shadowed: boolean; localVars: Set }[] + ): { shadowed: boolean; localVars: Set } | null { + if (ts.isBlock(node) || ts.isFunctionLike(node) || ts.isCatchClause(node)) { + const parentScope = scopeStack[scopeStack.length - 1]; + const newScope = { + shadowed: parentScope.shadowed, + localVars: new Set() + }; + scopeStack.push(newScope); + return newScope; + } + return null; + } + + static getVariablesFromScope( + node: ts.Node, + varName: string, + scopeStack: { shadowed: boolean; localVars: Set }[] + ): void { + if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === varName) { + const parent = node.parent; + if ( + ts.isVariableDeclarationList(parent) && + (parent.flags & ts.NodeFlags.Let || parent.flags & ts.NodeFlags.Const) + ) { + scopeStack[scopeStack.length - 1].localVars.add(varName); + } + } + + if (ts.isParameter(node) && ts.isIdentifier(node.name) && node.name.text === varName) { + scopeStack[scopeStack.length - 1].localVars.add(varName); + } + } + + private static isVariableModified( + node: ts.Node, + varName: string, + scopeStack: { shadowed: boolean; localVars: Set }[] + ): boolean { + if (!ts.isBinaryExpression(node) || node.operatorToken.kind !== ts.SyntaxKind.EqualsToken) { + return false; + } + + if (!ts.isIdentifier(node.left) || node.left.text !== varName) { + return false; + } + + for (let i = scopeStack.length - 1; i >= 0; i--) { + if (scopeStack[i].localVars.has(varName)) { + return false; + } + } + + return true; + } + + static checkVarModifiedBeforeNode(container: ts.Node, targetNode: ts.Node, varName: string): boolean { + const scopeStack: { shadowed: boolean; localVars: Set }[] = []; + scopeStack.push({ shadowed: false, localVars: new Set() }); + + const state = { + targetFound: false, + modified: false + }; + + this.traverseNodesUntilTarget(container, targetNode, varName, scopeStack, state); + return state.modified; + } + + static isFunctionCall(node: ts.Node): boolean { + return ts.isCallExpression(node) || ts.isArrowFunction(node) || ts.isFunctionExpression(node); + } + + private getArrayAccessInfo(expr: ts.ElementAccessExpression): false | ArrayAccess { + if (!ts.isIdentifier(expr.expression)) { + return false; + } + const baseType = this.tsTypeChecker.getTypeAtLocation(expr.expression); + if (!this.tsUtils.isArray(baseType)) { + return false; + } + const accessArgument = expr.argumentExpression; + + TypeScriptLinter.isFunctionCall(accessArgument); + + const checkNumericType = (node: ts.Node): boolean => { + const argType = this.tsTypeChecker.getTypeAtLocation(node); + return ( + (argType.flags & ts.TypeFlags.NumberLike) !== 0 || + argType.isUnionOrIntersection() && + argType.types.some((t) => { + return t.flags & ts.TypeFlags.NumberLike; + }) + ); + }; + + const isEnumMember = (node: ts.Node): boolean => { + if (ts.isPropertyAccessExpression(node)) { + const symbol = this.tsUtils.trueSymbolAtLocation(node); + return !!symbol && (symbol.flags & ts.SymbolFlags.EnumMember) !== 0; + } + return false; + }; + + if (TypeScriptLinter.isFunctionCall(accessArgument)) { + return false; + } + + if (checkNumericType(accessArgument) || isEnumMember(accessArgument)) { + return { + pos: expr.getEnd(), + accessingIdentifier: accessArgument, + arrayIdent: expr.expression + }; + } + + return false; + } } diff --git a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts index 8b54a99d038efb82dfbb5aa80fcc17f234e91d79..9a990259ea0cad8df51146c13bef1ff9342b114f 100644 --- a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts +++ b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts @@ -38,8 +38,8 @@ export const cookBookRefToFixTitle: Map = new Map([ [177, 'Add \'Sendable\' decorator'], [180, 'Remove the decorator'], [189, 'Add type annotations to numerical variables'], + [192, 'Use "undefined" instead "void"'], [193, 'Replace with arrow function'], - [206, 'Replace with a special library to call'], [209, 'Transform "number" to "int"'], [251, 'Transform "!!" to "$$()"'], [252, 'Transform "$$" to "$$()"'], @@ -52,6 +52,9 @@ export const cookBookRefToFixTitle: Map = new Map([ [260, '"@Entry" annotaion fixed'], [263, '"@Provide" annotation fixed'], [275, 'Custom layout need add decorator'], + [281, '"@Prop" transform to "@PropRef"'], + [282, '"@StorageProp" transform to "@StoragePropRef"'], + [283, '"@LocalStorageProp" transform to "@LocalStoragePropRef"'], [300, 'Replace calling method of the TS-like `Function` type'], [330, 'Convert import named objects from JS to ESValue'], [332, 'Using the ESValue interface to access properties'], diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 564ebc117d6aab1fc815b6d3331695fdf5f3ac17..dc78eabc871967312325792084c595295675ce3b 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -39,9 +39,11 @@ import { GET_LOCAL_STORAGE_FUNC_NAME, PROVIDE_DECORATOR_NAME, PROVIDE_ALIAS_PROPERTY_NAME, - PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME + PROVIDE_ALLOW_OVERRIDE_PROPERTY_NAME, + NEW_PROP_DECORATOR_SUFFIX } from '../utils/consts/ArkuiConstants'; import { ES_VALUE } from '../utils/consts/ESObject'; +import type { IncrementDecrementNodeInfo } from '../utils/consts/InteropAPI'; import { LOAD, GET_PROPERTY_BY_NAME, @@ -53,8 +55,11 @@ import { WRAP, INSTANTIATE, TO_NUMBER, + TO_PROMISE, INVOKE, - INVOKE_METHOD + INVOKE_METHOD, + LENGTH, + IS_INSTANCE_OF } from '../utils/consts/InteropAPI'; import { ESLIB_SHAREDARRAYBUFFER } from '../utils/consts/ConcurrentAPI'; @@ -86,6 +91,9 @@ const GENERATED_DESTRUCT_ARRAY_TRESHOLD = 1000; const GENERATED_IMPORT_VARIABLE_NAME = 'GeneratedImportVar_'; const GENERATED_IMPORT_VARIABLE_TRESHOLD = 1000; +const GENERATED_TMP_VARIABLE_NAME = 'tmp_'; +const GENERATED_TMP_VARIABLE_TRESHOLD = 1000; + const SPECIAL_LIB_NAME = 'specialAutofixLib'; const OBJECT_LITERAL_CLASS_CONSTRUCTOR_PARAM_NAME = 'init'; @@ -150,6 +158,11 @@ export class Autofixer { GENERATED_IMPORT_VARIABLE_TRESHOLD ); + private readonly tmpVariableNameGenerator = new NameGenerator( + GENERATED_TMP_VARIABLE_NAME, + GENERATED_TMP_VARIABLE_TRESHOLD + ); + private modVarName: string = ''; private readonly lastImportEndMap = new Map(); @@ -962,7 +975,43 @@ export class Autofixer { return this.renameSymbolAsIdentifier(symbol, enumMember); } + renameAsObjectElementAccessExpression(node: ts.ElementAccessExpression): Autofix[] | undefined { + const parenExpr = ts.isParenthesizedExpression(node.expression) ? node.expression : undefined; + const asExpr = parenExpr && ts.isAsExpression(parenExpr.expression) ? parenExpr.expression : undefined; + if (!asExpr) { + return undefined; + } + + const argument = node.argumentExpression; + const propertyName = ts.isStringLiteral(argument) ? argument.text : undefined; + if (!propertyName) { + return undefined; + } + + const realObj = asExpr.expression; + const type = this.typeChecker.getTypeAtLocation(realObj); + const property = this.typeChecker.getPropertyOfType(type, propertyName); + if (!property) { + return undefined; + } + + return [ + { + replacementText: realObj.getText() + '.' + propertyName, + start: node.getStart(), + end: node.getEnd() + } + ]; + } + fixPropertyAccessByIndex(node: ts.ElementAccessExpression): Autofix[] | undefined { + if (ts.isParenthesizedExpression(node.expression) && ts.isAsExpression(node.expression.expression)) { + const assertedType = this.typeChecker.getTypeAtLocation(node.expression.expression.type); + if (this.typeChecker.typeToString(assertedType) === 'object') { + return this.renameAsObjectElementAccessExpression(node); + } + } + const symbol = this.typeChecker.getSymbolAtLocation(node.argumentExpression); if (symbol === undefined) { return undefined; @@ -2013,7 +2062,8 @@ export class Autofixer { private fixObjectLiteralAsClass( objectLiteralExpr: ts.ObjectLiteralExpression, typeDecl: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined, - enclosingStmt: ts.Node + enclosingStmt: ts.Node, + typeNode?: ts.TypeReferenceNode ): Autofix[] | undefined { if (this.utils.nodeCapturesValueFromEnclosingLocalScope(objectLiteralExpr, enclosingStmt)) { return undefined; @@ -2032,9 +2082,9 @@ export class Autofixer { const classDeclAndCtorInitProps = this.createClassDeclForObjectLiteral( objectLiteralExpr, enclosingStmt, - newClassName, - newInitInterfaceName, - typeDecl + { className: newClassName, initInterfaceName: newInitInterfaceName }, + typeDecl, + typeNode ); if (!classDeclAndCtorInitProps) { return undefined; @@ -2063,10 +2113,11 @@ export class Autofixer { private createClassDeclForObjectLiteral( objectLiteralExpr: ts.ObjectLiteralExpression, enclosingStmt: ts.Node, - newClassName: string, - newInitInterfaceName: string, - typeDecl: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + names: { className: string; initInterfaceName: string }, + typeDecl: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined, + typeNode?: ts.TypeReferenceNode ): { classDecl: ts.ClassDeclaration; ctorInitProps: ts.PropertyAssignment[] } | undefined { + const { className, initInterfaceName } = names; const classFields: ts.PropertyDeclaration[] = []; const classMethods: (ts.MethodDeclaration | ts.AccessorDeclaration)[] = []; const ctorBodyStmts: ts.Statement[] = []; @@ -2096,14 +2147,14 @@ export class Autofixer { const classElements: ts.ClassElement[] = [...classFields]; if (ctorInitProps.length) { - classElements.push(Autofixer.createClassConstructorForObjectLiteral(newInitInterfaceName, ctorBodyStmts)); + classElements.push(Autofixer.createClassConstructorForObjectLiteral(initInterfaceName, ctorBodyStmts)); } classElements.push(...classMethods); - const heritageClauses = Autofixer.createHeritageClausesForObjectLiteralClass(typeDecl); + const heritageClauses = Autofixer.createHeritageClausesForObjectLiteralClass(typeDecl, typeNode); return { - classDecl: ts.factory.createClassDeclaration(undefined, newClassName, undefined, heritageClauses, classElements), + classDecl: ts.factory.createClassDeclaration(undefined, className, undefined, heritageClauses, classElements), ctorInitProps }; } @@ -2162,20 +2213,32 @@ export class Autofixer { } private static createHeritageClausesForObjectLiteralClass( - typeDecl: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined + typeDecl: ts.ClassDeclaration | ts.InterfaceDeclaration | undefined, + typeNode?: ts.TypeReferenceNode ): ts.HeritageClause[] | undefined { if (!typeDecl?.name) { return undefined; } + const heritageTypeExpression = typeNode ? + Autofixer.entityNameToExpression(typeNode.typeName) : + ts.factory.createIdentifier(typeDecl.name.text); + return [ ts.factory.createHeritageClause( ts.isClassDeclaration(typeDecl) ? ts.SyntaxKind.ExtendsKeyword : ts.SyntaxKind.ImplementsKeyword, - [ts.factory.createExpressionWithTypeArguments(typeDecl.name, undefined)] + [ts.factory.createExpressionWithTypeArguments(heritageTypeExpression, undefined)] ) ]; } + private static entityNameToExpression(name: ts.EntityName): ts.Expression { + if (ts.isQualifiedName(name)) { + return ts.factory.createPropertyAccessExpression(Autofixer.entityNameToExpression(name.left), name.right); + } + return ts.factory.createIdentifier(name.text); + } + private static createClassConstructorForObjectLiteral( newInitInterfaceName: string, ctorBodyStmts: ts.Statement[] @@ -2242,7 +2305,8 @@ export class Autofixer { return undefined; } - return this.fixObjectLiteralAsClass(objectLiteralExpr, typeDecl, enclosingStmt); + const typeNode = (objectLiteralExpr.parent as ts.VariableDeclaration).type as ts.TypeReferenceNode | undefined; + return this.fixObjectLiteralAsClass(objectLiteralExpr, typeDecl, enclosingStmt, typeNode); } private hasMethodOverridingProperty( @@ -2483,12 +2547,6 @@ export class Autofixer { return undefined; } - fixGlobalThisGet(node: ts.PropertyAccessExpression): Autofix[] { - void this; - const replacement = `${SPECIAL_LIB_NAME}.globalThis.get("${node.name.text}")`; - return [{ start: node.getStart(), end: node.getEnd(), replacementText: replacement }]; - } - fixVoidOperator(voidExpr: ts.VoidExpression): Autofix[] { let newExpr = voidExpr.expression; @@ -2619,12 +2677,6 @@ export class Autofixer { return { pattern, flag }; } - fixDebuggerStatement(debuggerStmt: ts.DebuggerStatement): Autofix[] { - void this; - const text = SPECIAL_LIB_NAME + '.debugger();'; - return [{ start: debuggerStmt.getStart(), end: debuggerStmt.getEnd(), replacementText: text }]; - } - /* * "unsafe" (result is not common subset) autofixes */ @@ -3063,6 +3115,229 @@ export class Autofixer { } } + private getVariableName(node: ts.Node): string | undefined { + let variableName: string | undefined; + + switch (node.kind) { + case ts.SyntaxKind.BinaryExpression: { + const binaryExpr = node as ts.BinaryExpression; + if (binaryExpr.operatorToken.kind !== ts.SyntaxKind.EqualsToken) { + return undefined; + } + + variableName = binaryExpr.left.getText(); + break; + } + case ts.SyntaxKind.VariableDeclaration: { + const variableDecl = node as ts.VariableDeclaration; + variableName = variableDecl.name.getText(); + break; + } + case ts.SyntaxKind.ExpressionStatement: { + variableName = TsUtils.generateUniqueName(this.tmpVariableNameGenerator, this.sourceFile); + break; + } + default: { + return undefined; + } + } + + return variableName; + } + + private getNewNodesForIncrDecr(variableName: string, operator: number): IncrementDecrementNodeInfo | undefined { + let update: string | undefined; + let updateNode: ts.BinaryExpression | undefined; + + switch (operator) { + case ts.SyntaxKind.MinusMinusToken: { + const { varAssignText, addOrDecrOperation } = this.createNewIncrDecrNodes( + variableName, + ts.SyntaxKind.MinusToken + ); + update = varAssignText; + updateNode = addOrDecrOperation; + break; + } + case ts.SyntaxKind.PlusPlusToken: { + const { varAssignText, addOrDecrOperation } = this.createNewIncrDecrNodes( + variableName, + ts.SyntaxKind.PlusToken + ); + update = varAssignText; + updateNode = addOrDecrOperation; + break; + } + default: + return undefined; + } + + return { varAssignText: update, addOrDecrOperation: updateNode }; + } + + fixUnaryIncrDecr( + node: ts.PrefixUnaryExpression | ts.PostfixUnaryExpression, + pan: ts.PropertyAccessExpression + ): Autofix[] | undefined { + const parent = node.parent; + const grandParent = parent.parent; + + const { expression, name } = pan; + const { operator } = node; + const isVariableDeclaration = ts.isVariableDeclaration(node.parent); + + const variableName = this.getVariableName(node.parent); + + if (!variableName) { + return undefined; + } + + const updateNodes = this.getNewNodesForIncrDecr(variableName, operator); + + if (!updateNodes?.varAssignText || !updateNodes.addOrDecrOperation) { + return undefined; + } + + const replacementText = this.getReplacementTextForPrefixAndPostfixUnary( + node, + updateNodes, + expression, + name, + variableName + ); + + if (!replacementText) { + return undefined; + } + + if (isVariableDeclaration) { + const start = grandParent.getStart(); + const end = grandParent.getEnd(); + return [{ replacementText, start, end }]; + } + + const start = parent.getStart(); + const end = parent.getEnd(); + return [{ replacementText, start, end }]; + } + + private getReplacementTextForPrefixAndPostfixUnary( + node: ts.Node, + updateNodes: IncrementDecrementNodeInfo, + expression: ts.LeftHandSideExpression, + name: ts.MemberName, + variableName: string + ): string | undefined { + const { varAssignText, addOrDecrOperation } = updateNodes; + const converted: ts.Node = this.createGetPropertyForIncrDecr(expression.getText(), name.text); + let convertedAssigned = ''; + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken) { + convertedAssigned = this.wrapPropertyAccessInBinaryExpr(variableName, converted); + } else { + convertedAssigned = this.wrapPropertyAccessInVariableDeclaration(variableName, converted); + } + let replacementText = ''; + + switch (node.kind) { + case ts.SyntaxKind.PrefixUnaryExpression: { + const assign = this.createSetProperty( + expression.getText(), + name.text, + ts.factory.createIdentifier(variableName) + ); + replacementText = `${convertedAssigned}\n${varAssignText}\n${assign}\n`; + break; + } + case ts.SyntaxKind.PostfixUnaryExpression: { + const assign = this.createSetProperty(expression.getText(), name.text, addOrDecrOperation as ts.Expression); + replacementText = `${convertedAssigned}\n${assign}\n${varAssignText}\n`; + break; + } + default: { + return undefined; + } + } + + return replacementText; + } + + private wrapPropertyAccessInVariableDeclaration(variableName: string, wrappedNode: ts.Node): string { + const node = ts.factory.createVariableDeclarationList( + [ + ts.factory.createVariableDeclaration( + ts.factory.createIdentifier(variableName), + undefined, + undefined, + wrappedNode as ts.Expression + ) + ], + ts.NodeFlags.Let + ); + + return this.printer.printNode(ts.EmitHint.Unspecified, node, this.sourceFile); + } + + private wrapPropertyAccessInBinaryExpr(variableName: string, wrappedNode: ts.Node): string { + const node = ts.factory.createBinaryExpression( + ts.factory.createIdentifier(variableName), + ts.SyntaxKind.EqualsToken, + wrappedNode as ts.Expression + ); + + return this.printer.printNode(ts.EmitHint.Unspecified, node, this.sourceFile); + } + + private createGetPropertyForIncrDecr(expression: string, name: string): ts.Node { + void this; + return ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(expression), + ts.factory.createIdentifier(GET_PROPERTY_BY_NAME) + ), + undefined, + [ts.factory.createStringLiteral(name)] + ), + ts.factory.createIdentifier(TO_NUMBER) + ), + undefined, + [] + ); + } + + private createNewIncrDecrNodes(variableName: string, token: number): IncrementDecrementNodeInfo { + const update = ts.factory.createBinaryExpression( + ts.factory.createIdentifier(variableName), + ts.factory.createToken(token), + ts.factory.createNumericLiteral('1') + ); + + const node = ts.factory.createBinaryExpression( + ts.factory.createIdentifier(variableName), + ts.factory.createToken(ts.SyntaxKind.EqualsToken), + update + ); + + return { + addOrDecrOperation: update, + varAssignText: this.printer.printNode(ts.EmitHint.Unspecified, node, this.sourceFile) + }; + } + + private createSetProperty(expression: string, field: string, value: ts.Expression): string { + const node = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(expression), + ts.factory.createIdentifier(SET_PROPERTY_BY_NAME) + ), + undefined, + [ts.factory.createIdentifier(field), value] + ); + + return this.printer.printNode(ts.EmitHint.Unspecified, node, this.sourceFile); + } + fixVariableDeclaration(node: ts.VariableDeclaration, isEnum: boolean): Autofix[] | undefined { const initializer = node.initializer; const name = node.name; @@ -3106,7 +3381,11 @@ export class Autofixer { node.initializer ); - const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, newProperty, node.getSourceFile()); + const replacementText = this.nonCommentPrinter.printNode( + ts.EmitHint.Unspecified, + newProperty, + node.getSourceFile() + ); return [ { @@ -3231,7 +3510,7 @@ export class Autofixer { initializer ); - const text = this.printer.printNode(ts.EmitHint.Unspecified, newPropDecl, node.getSourceFile()); + const text = this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, newPropDecl, node.getSourceFile()); return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; } @@ -3594,6 +3873,30 @@ export class Autofixer { return [{ start: binaryExpr.getStart(), end: binaryExpr.getEnd(), replacementText }]; } + /** + * Autofix for `foo instanceof Foo` → `foo.isInstanceOf(Foo)`. + * + * @param node The binary `instanceof` expression node. + * @returns A single Autofix replacing the entire `foo instanceof Foo` text. + */ + fixInteropJsInstanceOfExpression(node: ts.BinaryExpression): Autofix[] { + // left-hand and right-hand operands of the `instanceof` + const leftExpr = node.left; + const rightExpr = node.right; + + // build: leftExpr.isInstanceOf(rightExpr) + const callExpr = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(leftExpr, ts.factory.createIdentifier(IS_INSTANCE_OF)), + undefined, + [rightExpr] + ); + + // render back to source text + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, callExpr, node.getSourceFile()); + + return [{ replacementText, start: node.getStart(), end: node.getEnd() }]; + } + createReplacementForJsIndirectImportPropertyAccessExpression(node: ts.PropertyAccessExpression): Autofix[] { // Bypass eslint-check void this; @@ -3603,7 +3906,7 @@ export class Autofixer { let start = node.getStart(); let end = node.getEnd(); - let replacementText = `${objName}.getPropertyByName('${propName}')`; + let replacementText = `${objName}.${GET_PROPERTY_BY_NAME}('${propName}')`; // Check if there is an "as number" type assertion in the statement if (ts.isAsExpression(node.parent) && node.parent.type.kind === ts.SyntaxKind.NumberKeyword) { @@ -3622,29 +3925,93 @@ export class Autofixer { const start = node.getStart(); const end = node.getEnd(); - const replacement = `${objName}.getPropertyByName('${propName}')${this.utils.findTypeOfNodeForConversion(node)}`; + const typeTag = this.utils.findTypeOfNodeForConversion(node); + const replacement = `${objName}.${GET_PROPERTY_BY_NAME}('${propName}')${typeTag}`; return [{ replacementText: replacement, start, end }]; } - createReplacementJsImportElementAccessExpression( - elementAccessExpr: ts.ElementAccessExpression, - identifier: ts.Identifier - ): Autofix[] { - const isParentBinaryExp = ts.isBinaryExpression(elementAccessExpr.parent); - const exprText = elementAccessExpr.argumentExpression.getText(); - const start = isParentBinaryExp ? elementAccessExpr.parent.getStart() : elementAccessExpr.getStart(); - const end = isParentBinaryExp ? elementAccessExpr.parent.getEnd() : elementAccessExpr.getEnd(); - - const replacementText = - isParentBinaryExp && elementAccessExpr.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken ? - `${identifier.text}.setPropertyByIndex(${exprText},` + - ` ESValue.wrap(${elementAccessExpr.parent.right.getText()}))` : - `${identifier.text}.getPropertyByIndex(${exprText})` + - this.utils.findTypeOfNodeForConversion(elementAccessExpr); + /** + * Converts a JS element access (e.g. `arr[index]`) into the corresponding + * interop call: + * - On assignment (`arr[index] = value`), emits `arr.setPropertyByIndex(index, ESValue.wrap(value))` + * - On read, emits `arr.getPropertyByIndex(index)` plus any type conversion suffix + * + * @param elementAccessExpr The original `ElementAccessExpression` node. + * @returns An array with a single `Autofix` describing the replacement range and text. + */ + fixJsImportElementAccessExpression(elementAccessExpr: ts.ElementAccessExpression): Autofix[] { + const parent = elementAccessExpr.parent; + + const isAssignment = + parent !== undefined && ts.isBinaryExpression(parent) && parent.operatorToken.kind === ts.SyntaxKind.EqualsToken; + + // array identifier (e.g. "arr") + const identifierNode = elementAccessExpr.expression as ts.Identifier; + + let replacementText: string; + if (isAssignment) { + // arr.setPropertyByIndex(index, ESValue.wrap(value)) + const wrapped = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(ES_VALUE), + ts.factory.createIdentifier(WRAP) + ), + undefined, + [parent.right] + ); + + const callExpr = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(identifierNode, ts.factory.createIdentifier(SET_PROPERTY_BY_INDEX)), + undefined, + [elementAccessExpr.argumentExpression, wrapped] + ); + + replacementText = this.printer.printNode(ts.EmitHint.Unspecified, callExpr, elementAccessExpr.getSourceFile()); + } else { + // arr.getPropertyByIndex(index) plus conversion + const callExpr = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(identifierNode, ts.factory.createIdentifier(GET_PROPERTY_BY_INDEX)), + undefined, + [elementAccessExpr.argumentExpression] + ); + + replacementText = + this.printer.printNode(ts.EmitHint.Unspecified, callExpr, elementAccessExpr.getSourceFile()) + + this.utils.findTypeOfNodeForConversion(elementAccessExpr); + } + + const start = isAssignment ? (parent as ts.Node).getStart() : elementAccessExpr.getStart(); + const end = isAssignment ? (parent as ts.Node).getEnd() : elementAccessExpr.getEnd(); + return [{ replacementText, start, end }]; } + /** + * Replace each loop‐variable reference (e.g. `element`) with + * `array.getPropertyByIndex(i)` plus appropriate conversion. + * + * @param identifier The Identifier node of the loop variable usage. + * @param arrayName The name of the array being iterated. + */ + fixInteropArrayElementUsage(identifier: ts.Identifier, arrayName: string): Autofix { + // arr.getPropertyByIndex(i) + const callExpr = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(arrayName), + ts.factory.createIdentifier(GET_PROPERTY_BY_INDEX) + ), + undefined, + [ts.factory.createIdentifier('i')] + ); + + // Print and append proper conversion suffix + const printed = this.printer.printNode(ts.EmitHint.Unspecified, callExpr, identifier.getSourceFile()); + const replacementText = printed + this.utils.findTypeOfNodeForConversion(identifier); + + return { replacementText, start: identifier.getStart(), end: identifier.getEnd() }; + } + fixSharedArrayBufferConstructor(node: ts.NewExpression): Autofix[] | undefined { void this; @@ -3671,6 +4038,63 @@ export class Autofixer { return [{ replacementText, start: node.getStart(), end: node.getEnd() }]; } + /** + * Converts a `for...of` over an interop array into + * an index-based `for` loop using `getPropertyByName("length")`. + * + * @param node The `ForOfStatement` node to fix. + * @returns A single Autofix for the loop header replacement. + */ + fixInteropArrayForOf(node: ts.ForOfStatement): Autofix { + const iterableName = node.expression.getText(); + + const initializer = ts.factory.createVariableDeclarationList( + [ + ts.factory.createVariableDeclaration( + ts.factory.createIdentifier('i'), + undefined, + undefined, + ts.factory.createNumericLiteral('0') + ) + ], + ts.NodeFlags.Let + ); + + const lengthAccess = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(iterableName), + ts.factory.createIdentifier(GET_PROPERTY_BY_NAME) + ), + undefined, + [ts.factory.createStringLiteral(LENGTH)] + ); + const condition = ts.factory.createBinaryExpression( + ts.factory.createIdentifier('i'), + ts.SyntaxKind.LessThanToken, + lengthAccess + ); + + const incrementor = ts.factory.createPrefixUnaryExpression( + ts.SyntaxKind.PlusPlusToken, + ts.factory.createIdentifier('i') + ); + + // Render just the "(initializer; condition; incrementor)" text: + const headerText = [ + this.printer.printNode(ts.EmitHint.Unspecified, initializer, node.getSourceFile()), + '; ', + this.printer.printNode(ts.EmitHint.Unspecified, condition, node.getSourceFile()), + '; ', + this.printer.printNode(ts.EmitHint.Unspecified, incrementor, node.getSourceFile()) + ].join(''); + + // Only replace from the start of the initializer to the end of the 'of' expression + const start = node.initializer.getStart(); + const end = node.expression.getEnd(); + + return { start, end, replacementText: headerText }; + } + fixAppStorageCallExpression(callExpr: ts.CallExpression): Autofix[] | undefined { const varDecl = Autofixer.findParentVariableDeclaration(callExpr); if (!varDecl || varDecl.type) { @@ -3757,30 +4181,52 @@ export class Autofixer { return ''; } - private static fixInterOpImportJsWrapArgs(args: ts.NodeArray): string { - return args. - map((arg) => { - return `ESValue.wrap(${arg.getText()})`; - }). - join(', '); - } - - private fixInterOpImportJsProcessNode(node: ts.Node): string { + private fixInterOpImportJsProcessNode(node: ts.Node): string | undefined { if (ts.isIdentifier(node)) { return node.text; } else if (ts.isCallExpression(node)) { - const callee = this.fixInterOpImportJsProcessNode(node.expression); - const args = Autofixer.fixInterOpImportJsWrapArgs(node.arguments); - return `${callee}.invoke(${args})`; + const newArgs = this.createArgs(node.arguments); + const callee = node.expression; + switch (callee.kind) { + case ts.SyntaxKind.PropertyAccessExpression: { + const propertyAccessExpr = node.expression as ts.PropertyAccessExpression; + const newCallExpr = this.createJSInvokeCallExpression(propertyAccessExpr.expression, INVOKE_METHOD, [ + ts.factory.createStringLiteral(propertyAccessExpr.name.text), + ...newArgs || [] + ]); + + if (!newCallExpr) { + return undefined; + } + return this.printer.printNode(ts.EmitHint.Unspecified, newCallExpr, node.getSourceFile()); + } + default: { + const callExpr = this.createJSInvokeCallExpression(node.expression, INVOKE, [...newArgs || []]); + + if (!callExpr) { + return undefined; + } + + return this.printer.printNode(ts.EmitHint.Unspecified, callExpr, node.getSourceFile()); + } + } } else if (ts.isPropertyAccessExpression(node)) { const base = this.fixInterOpImportJsProcessNode(node.expression); + if (!base) { + return undefined; + } const propName = node.name.text; - return `${base}.getPropertyByName('${propName}')`; + return `${base}.${GET_PROPERTY_BY_NAME}('${propName}')`; } else if (ts.isNewExpression(node)) { - const constructor = this.fixInterOpImportJsProcessNode(node.expression); - return `${constructor}.instantiate()`; + const newArgs = this.createArgs(node.arguments); + const newCallExpr = this.createJSInvokeCallExpression(node.expression, INSTANTIATE, [...newArgs || []]); + + if (!newCallExpr) { + return undefined; + } + return this.printer.printNode(ts.EmitHint.Unspecified, newCallExpr, node.getSourceFile()); } - return ''; + return undefined; } fixInterOpImportJs( @@ -3946,6 +4392,65 @@ export class Autofixer { ]; } + fixInteropOperators(expr: ts.Expression): Autofix[] | undefined { + if (ts.isPropertyAccessExpression(expr)) { + return this.fixPropertyAccessToNumber(expr); + } + + if (ts.isIdentifier(expr)) { + const symbol = this.utils.trueSymbolAtLocation(expr); + + if (this.utils.isJsImport(expr)) { + const toNumberCall = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(expr, ts.factory.createIdentifier(TO_NUMBER)), + undefined, + [] + ); + + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, toNumberCall, expr.getSourceFile()); + + return [ + { + start: expr.getStart(), + end: expr.getEnd(), + replacementText + } + ]; + } + + const decl = symbol?.declarations?.find(ts.isVariableDeclaration); + if (decl?.initializer && ts.isPropertyAccessExpression(decl.initializer)) { + return this.fixPropertyAccessToNumber(decl.initializer); + } + } + + return undefined; + } + + private fixPropertyAccessToNumber(expr: ts.PropertyAccessExpression): Autofix[] { + const getPropCall = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(expr.expression, ts.factory.createIdentifier(GET_PROPERTY_BY_NAME)), + undefined, + [ts.factory.createStringLiteral(expr.name.getText())] + ); + + const toNumberCall = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(getPropCall, ts.factory.createIdentifier(TO_NUMBER)), + undefined, + [] + ); + + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, toNumberCall, expr.getSourceFile()); + + return [ + { + start: expr.getStart(), + end: expr.getEnd(), + replacementText + } + ]; + } + fixInteropArrayElementAccessExpression(express: ts.ElementAccessExpression): Autofix[] | undefined { const statements = ts.factory.createCallExpression( ts.factory.createPropertyAccessExpression(express.expression, ts.factory.createIdentifier(GET_PROPERTY_BY_INDEX)), @@ -3986,8 +4491,11 @@ export class Autofixer { const start = typeofExpress.getStart(); const end = typeofExpress.getEnd(); const processed = this.fixInterOpImportJsProcessNode(node); + if (!processed) { + return undefined; + } const replacementText = `${processed}.typeOf()`; - return replacementText ? [{ start, end, replacementText }] : undefined; + return [{ start, end, replacementText }]; } fixInteropInterfaceConvertNum(express: ts.PrefixUnaryExpression): Autofix[] | undefined { @@ -4122,7 +4630,7 @@ export class Autofixer { fixNoTsLikeFunctionCall(identifier: ts.Node): Autofix[] { void this; const funcName = identifier.getText(); - const replacementText = `${funcName}.unSafeCall`; + const replacementText = `${funcName}.unsafeCall`; return [ { replacementText, @@ -4209,24 +4717,208 @@ export class Autofixer { return !builtInTypes.has(type.typeName.getText()); } + fixLimitedVoidType( + node: ts.VariableDeclaration | ts.ParameterDeclaration | ts.PropertyDeclaration + ): Autofix[] | undefined { + const srcFile = node.getSourceFile(); + const newType = Autofixer.createNewTypeFromVoid(node.type); + const newInit = Autofixer.createNewInitializer(node.initializer, newType); + + const newDecl = Autofixer.createNewDeclaration(node, newType, newInit); + if (!newDecl) { + return undefined; + } + + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, newDecl, srcFile); + return [{ start: node.getStart(), end: node.getEnd(), replacementText }]; + } + + private static createNewTypeFromVoid(type: ts.TypeNode | undefined): ts.TypeNode { + const identUndefined = ts.factory.createIdentifier(UNDEFINED_NAME); + if (type && ts.isUnionTypeNode(type)) { + const updatedTypes = type.types.map((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword ? ts.factory.createTypeReferenceNode(UNDEFINED_NAME) : t; + }); + return ts.factory.createUnionTypeNode(updatedTypes); + } + return ts.factory.createTypeReferenceNode(identUndefined); + } + + private static createNewInitializer(initializer: ts.Expression | undefined, newType: ts.TypeNode): ts.Expression { + const identUndefined = ts.factory.createIdentifier(UNDEFINED_NAME); + if (!initializer) { + return identUndefined; + } + + const stmts: ts.Statement[] = [ + ts.factory.createExpressionStatement(initializer), + ts.factory.createReturnStatement(identUndefined) + ]; + const funcBody = ts.factory.createBlock(stmts); + const arrowFunc = ts.factory.createArrowFunction( + undefined, + undefined, + [], + newType, + ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + funcBody + ); + return ts.factory.createCallExpression(ts.factory.createParenthesizedExpression(arrowFunc), undefined, undefined); + } + + private static createNewDeclaration( + node: ts.VariableDeclaration | ts.ParameterDeclaration | ts.PropertyDeclaration, + newType: ts.TypeNode, + newInit: ts.Expression + ): ts.Node | undefined { + if (ts.isVariableDeclaration(node)) { + return ts.factory.createVariableDeclaration(node.name, node.exclamationToken, newType, newInit); + } + + if (ts.isParameter(node)) { + return ts.factory.createParameterDeclaration( + node.modifiers, + node.dotDotDotToken, + node.name, + node.questionToken, + newType, + node.initializer ? newInit : undefined + ); + } + + if (ts.isPropertyDeclaration(node)) { + const optionalToken = node.questionToken || node.exclamationToken; + return ts.factory.createPropertyDeclaration(node.modifiers, node.name, optionalToken, newType, newInit); + } + + return undefined; + } + + /** + * Fixes function declarations/expressions that return `void` as part of a union. + * Replaces `void` with `undefined` in the return type, + * replaces `return;` with `return undefined;`, + * and adds `return undefined;` if the function has no returns. + */ + fixLimitedVoidTypeFunction(fn: ts.FunctionLikeDeclaration): Autofix[] | undefined { + const fixes: Autofix[] = []; + const returnType = fn.type; + if (!returnType || !ts.isUnionTypeNode(returnType) || !TsUtils.typeContainsVoid(returnType)) { + return undefined; + } + + const updatedTypes = returnType.types.map((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword ? ts.factory.createTypeReferenceNode(UNDEFINED_NAME) : t; + }); + + const newType = ts.factory.createUnionTypeNode(updatedTypes); + fixes.push({ + start: returnType.getStart(), + end: returnType.getEnd(), + replacementText: this.printer.printNode(ts.EmitHint.Unspecified, newType, fn.getSourceFile()) + }); + + let hasReturn = false; + function visit(node: ts.Node): void { + if (ts.isReturnStatement(node)) { + hasReturn = true; + if (!node.expression) { + fixes.push({ + start: node.getStart(), + end: node.getEnd(), + replacementText: 'return undefined;' + }); + } + } + ts.forEachChild(node, visit); + } + if (fn.body) { + visit(fn.body); + + if (!hasReturn) { + if (ts.isBlock(fn.body)) { + const lastBrace = fn.body.getEnd() - 1; + fixes.push({ + start: lastBrace, + end: lastBrace, + replacementText: '\nreturn undefined;\n' + }); + } + } + } + + return fixes; + } + + private fixGenericCallNoTypeArgsWithContextualType(node: ts.NewExpression): Autofix[] | undefined { + const contextualType = this.typeChecker.getContextualType(node); + if (!contextualType) { + return undefined; + } + + const typeArgs = Autofixer.getTypeArgumentsFromType(contextualType); + if (typeArgs.length === 0) { + return undefined; + } + const reference = typeArgs.map((arg) => { + return ts.factory.createTypeReferenceNode(this.typeChecker.typeToString(arg)); + }); + return this.generateGenericTypeArgumentsAutofix(node, reference); + } + fixGenericCallNoTypeArgs(node: ts.NewExpression): Autofix[] | undefined { const typeNode = this.getTypeNodeForNewExpression(node); - if (!typeNode || !ts.isTypeReferenceNode(typeNode) || typeNode.typeName.getText() !== node.expression.getText()) { + if (!typeNode) { + return this.fixGenericCallNoTypeArgsWithContextualType(node); + } + if (!ts.isTypeReferenceNode(typeNode) || typeNode.typeName.getText() !== node.expression.getText()) { return undefined; } - const reference: ts.TypeReferenceNode[] = []; - typeNode.typeArguments?.forEach((arg) => { - return reference.push(ts.factory.createTypeReferenceNode(arg.getText())); - }); + const srcFile = node.getSourceFile(); + const typeArgsText = `<${typeNode.typeArguments?. + map((arg) => { + 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 }]; + } + + private generateGenericTypeArgumentsAutofix( + node: ts.NewExpression, + typeArgs: ts.TypeReferenceNode[] + ): Autofix[] | undefined { const srcFile = node.getSourceFile(); const identifier = node.expression; const args = node.arguments; - const newExpression = ts.factory.createNewExpression(identifier, reference, args); + const hasValidArgs = typeArgs.some((arg) => { + return arg?.typeName && ts.isIdentifier(arg.typeName); + }); + if (!hasValidArgs) { + return undefined; + } + const hasAnyType = typeArgs.some((arg) => { + return ts.isIdentifier(arg?.typeName) && arg.typeName.text === 'any'; + }); + 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 }]; } + static getTypeArgumentsFromType(type: ts.Type): ts.Type[] { + const typeReference = type as ts.TypeReference; + if (typeReference.typeArguments) { + return [...typeReference.typeArguments]; + } + return []; + } + private getTypeNodeForNewExpression(node: ts.NewExpression): ts.TypeNode | undefined { if (ts.isVariableDeclaration(node.parent) || ts.isPropertyDeclaration(node.parent)) { return node.parent.type; @@ -4250,6 +4942,80 @@ export class Autofixer { return undefined; } + private createJSInvokeCallExpression( + ident: ts.Expression, + method: string, + args: ts.Expression[] | undefined + ): ts.CallExpression | undefined { + if (ts.isNewExpression(ident)) { + const instantiatedClass = this.createJSInvokeCallExpression( + ident.expression, + INSTANTIATE, + this.createArgs(ident.arguments) + ); + if (!instantiatedClass) { + return undefined; + } + return this.createJSInvokeCallExpression(instantiatedClass, method, args); + } + return ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(ident, ts.factory.createIdentifier(method)), + undefined, + args + ); + } + + fixAwaitJsCallExpression(ident: ts.Identifier, args: ts.NodeArray | undefined): Autofix[] | undefined { + const newArgs = this.createArgs(args); + + const newCallExpr = this.createJSInvokeCallExpression(ident, INVOKE, newArgs); + if (!newCallExpr) { + return undefined; + } + + const replacedNode = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(newCallExpr, ts.factory.createIdentifier(TO_PROMISE)), + undefined, + undefined + ); + + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, replacedNode, ident.getSourceFile()); + return [{ start: ident.parent.getStart(), end: ident.parent.getEnd(), replacementText }]; + } + + fixAwaitJsMethodCallExpression( + ident: ts.Identifier, + args: ts.NodeArray | undefined + ): Autofix[] | undefined { + const propertyAccessExpr = ident.parent as ts.PropertyAccessExpression; + const accessedProperty = propertyAccessExpr.expression; + const newArgs = this.createArgs(args); + + const newCallExpr = this.createJSInvokeCallExpression(accessedProperty, INVOKE_METHOD, [ + ts.factory.createStringLiteral(ident.text), + ...newArgs || [] + ]); + + if (!newCallExpr) { + return undefined; + } + + const replacedNode = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(newCallExpr, ts.factory.createIdentifier(TO_PROMISE)), + undefined, + undefined + ); + + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, replacedNode, ident.getSourceFile()); + return [{ start: propertyAccessExpr.parent.getStart(), end: propertyAccessExpr.parent.getEnd(), replacementText }]; + } + + fixAwaitJsPromise(ident: ts.Identifier): Autofix[] { + void this; + const replacementText = `${ident.text}.toPromise()`; + return [{ start: ident.getStart(), end: ident.getEnd(), replacementText }]; + } + fixMissingAttribute(node: ts.PropertyAccessExpression): Autofix[] { const exprName = node.expression.getText(); const propertyAccessExpr = ts.factory.createPropertyAccessExpression( @@ -4268,7 +5034,7 @@ export class Autofixer { fixCustomLayout(node: ts.StructDeclaration): Autofix[] { const startPos = Autofixer.getStartPositionWithoutDecorators(node); - const decorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomDecoratorName.Layoutable)); + const decorator = ts.factory.createDecorator(ts.factory.createIdentifier(CustomDecoratorName.CustomLayout)); const text = this.getNewLine() + this.printer.printNode(ts.EmitHint.Unspecified, decorator, node.getSourceFile()); return [{ start: startPos, end: startPos, replacementText: text }]; @@ -4285,6 +5051,35 @@ export class Autofixer { fixNumericLiteralIntToNumber(node: ts.NumericLiteral): Autofix[] | undefined { void this; - return [{ start: node.getStart(), end: node.getEnd(), replacementText: `${node.getText()}.0` }]; + let replacementText = node.getText(); + const parent = node.parent; + + if (ts.isPrefixUnaryExpression(parent) && parent.operator === ts.SyntaxKind.MinusToken) { + replacementText = `-${replacementText}.0`; + return [ + { + start: parent.getStart(), + end: node.getEnd(), + replacementText + } + ]; + } + + return [ + { + start: node.getStart(), + end: node.getEnd(), + replacementText: `${replacementText}.0` + } + ]; + } + + fixPropDecorator(node: ts.Decorator, decoratorName: string): Autofix[] { + const newDecorator = ts.factory.createDecorator( + ts.factory.createIdentifier(decoratorName + NEW_PROP_DECORATOR_SUFFIX) + ); + + const text = this.printer.printNode(ts.EmitHint.Unspecified, newDecorator, node.getSourceFile()); + return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; } } diff --git a/ets2panda/linter/src/lib/autofixes/QuasiEditor.ts b/ets2panda/linter/src/lib/autofixes/QuasiEditor.ts index 462d6d8b133f691bbc7767e37e33d303726b79ca..7d8aad85134f7babf281474ea14ecd7f28229f2c 100644 --- a/ets2panda/linter/src/lib/autofixes/QuasiEditor.ts +++ b/ets2panda/linter/src/lib/autofixes/QuasiEditor.ts @@ -20,6 +20,7 @@ import { Logger } from '../Logger'; import type { ProblemInfo } from '../ProblemInfo'; import type { Autofix } from './Autofixer'; import type { LinterOptions } from '../LinterOptions'; +import { USE_STATIC } from '../utils/consts/InteropAPI'; import { AUTOFIX_HTML_TEMPLATE_TEXT, AutofixHtmlTemplate } from './AutofixReportHtmlHelper'; const BACKUP_AFFIX = '~'; @@ -42,12 +43,6 @@ export class QuasiEditor { fs.copyFileSync(filePath, QuasiEditor.getBackupFileName(filePath)); } - static hasAnyAutofixes(problemInfos: ProblemInfo[]): boolean { - return problemInfos.some((problemInfo) => { - return problemInfo.autofix !== undefined; - }); - } - private generateReport(acceptedPatches: Autofix[]): void { const report = { filePath: this.srcFileName, @@ -95,14 +90,16 @@ export class QuasiEditor { } } - fix(problemInfos: ProblemInfo[]): string { + fix(problemInfos: ProblemInfo[], needAddUseStatic: boolean | undefined): string { const acceptedPatches = QuasiEditor.sortAndRemoveIntersections(problemInfos); - const result = this.applyFixes(acceptedPatches); + let result = this.applyFixes(acceptedPatches); if (this.linterOpts.migrationReport) { this.generateReport(acceptedPatches); } - + if (needAddUseStatic) { + result = QuasiEditor.addUseStaticDirective(result); + } return result; } @@ -196,4 +193,18 @@ export class QuasiEditor { */ return !(lhs.end < rhs.start || rhs.end < lhs.start); } + + private static addUseStaticDirective(content: string): string { + const lines = content.split('\n'); + if (lines.length > 0 && lines[0].trim() === USE_STATIC) { + return content; + } + return USE_STATIC + '\n' + content; + } + + static hasAnyAutofixes(problemInfos: ProblemInfo[]): boolean { + return problemInfos.some((problemInfo) => { + return problemInfo.autofix !== undefined; + }); + } } diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index 2327bf026c6769c0aebd3371a8236a1a6f0319de..7aa8050e888d46cb3c8a07b147c275ea479bc997 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -44,9 +44,8 @@ import { isIntrinsicObjectType } from './functions/isIntrinsicObjectType'; import type { LinterOptions } from '../LinterOptions'; import { ETS } from './consts/TsSuffix'; import { STRINGLITERAL_NUMBER, STRINGLITERAL_NUMBER_ARRAY } from './consts/StringLiteral'; -import { USE_STATIC } from './consts/InteropAPI'; import { ETS_MODULE, PATH_SEPARATOR, VALID_OHM_COMPONENTS_MODULE_PATH } from './consts/OhmUrl'; -import { EXTNAME_ETS, EXTNAME_JS } from './consts/ExtensionName'; +import { EXTNAME_ETS, EXTNAME_JS, EXTNAME_D_ETS } from './consts/ExtensionName'; import { STRING_ERROR_LITERAL } from './consts/Literals'; export const SYMBOL = 'Symbol'; @@ -2140,6 +2139,14 @@ export class TsUtils { return callSigns && callSigns.length > 0; } + static getFunctionReturnType(type: ts.Type): ts.Type | null { + const signatures = type.getCallSignatures(); + if (signatures.length === 0) { + return null; + } + return signatures[0].getReturnType(); + } + isStdFunctionType(type: ts.Type): boolean { const sym = type.getSymbol(); return !!sym && sym.getName() === 'Function' && this.isGlobalSymbol(sym); @@ -2175,8 +2182,10 @@ export class TsUtils { return true; } } - // We allow computed property names if expression is string literal or string Enum member - return ts.isStringLiteralLike(expr) || this.isEnumStringLiteral(computedProperty.expression); + // In ArkTS 1.0, the computed property names are allowed if expression is string literal or string Enum member. + return ( + !this.options.arkts2 && (ts.isStringLiteralLike(expr) || this.isEnumStringLiteral(computedProperty.expression)) + ); } skipPropertyInferredTypeCheck( @@ -3654,7 +3663,7 @@ export class TsUtils { ) { return false; } - + return true; } current = current.parent; @@ -3722,21 +3731,19 @@ export class TsUtils { return ( importSourceFile.fileName.endsWith(EXTNAME_ETS) && currentSourceFile.fileName.endsWith(EXTNAME_ETS) && - !TsUtils.isArkts12File(importSourceFile) && - TsUtils.isArkts12File(currentSourceFile) + !this.isArkts12File(importSourceFile) && + this.isArkts12File(currentSourceFile) ); } - static isArkts12File(sourceFile: ts.SourceFile): boolean { - if (!sourceFile?.statements.length) { + isArkts12File(sourceFile: ts.SourceFile): boolean { + if (!sourceFile?.fileName) { return false; } - const statements = sourceFile.statements; - return ( - ts.isExpressionStatement(statements[0]) && - ts.isStringLiteral(statements[0].expression) && - statements[0].expression.getText() === USE_STATIC - ); + if (sourceFile.fileName.endsWith(EXTNAME_D_ETS)) { + return true; + } + return !!this.options.inputFiles?.includes(path.normalize(sourceFile.fileName)); } static removeOrReplaceQuotes(str: string, isReplace: boolean): string { @@ -3808,4 +3815,13 @@ export class TsUtils { forEachNodeInSubtree(targetNode, callback, stopCondition); return found; } + + static typeContainsVoid(typeNode: ts.TypeNode): boolean { + if (ts.isUnionTypeNode(typeNode)) { + return typeNode.types.some((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword; + }); + } + return typeNode.kind === ts.SyntaxKind.VoidKeyword; + } } diff --git a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts index 74a8769931be1a31aef12b527d120e2f36261ba9..1f26e36e862aa393385cf635d5b726a41ec9c02c 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts @@ -21,6 +21,7 @@ export const arkts2Rules: number[] = [ 37, 29, 111, + 134, 137, 139, 140, @@ -69,7 +70,6 @@ export const arkts2Rules: number[] = [ 261, 262, 263, - 264, 265, 266, 267, @@ -78,6 +78,12 @@ export const arkts2Rules: number[] = [ 270, 274, 275, + 281, + 282, + 283, + 284, + 285, + 286, 300, 301, 302, diff --git a/ets2panda/linter/src/lib/utils/consts/ArkTSUtilsAPI.ts b/ets2panda/linter/src/lib/utils/consts/ArkTSUtilsAPI.ts index 8218ffc5113110bf9692d2a2f8ec847471e0dc93..bae5dc65cc4e7b65fd607f7142fcd376411b217d 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkTSUtilsAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkTSUtilsAPI.ts @@ -17,3 +17,5 @@ export const ASON_TEXT = 'ASON'; export const ASON_MODULES = ['@arkts.utils', '@kit.ArkTS']; export const JSON_TEXT = 'JSON'; export const ARKTS_UTILS_TEXT = 'ArkTSUtils'; + +export const ASON_WHITE_SET: Set = new Set(['stringify']); diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts index 159e986494df2c7703b94db0a30018f0c5a127a0..b12761975d76cbc0d90ea7086ecb24888d1e84e2 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiConstants.ts @@ -25,6 +25,7 @@ export const VALUE_IDENTIFIER = 'value'; export const INDENT_STEP = 2; export const MAKE_OBSERVED = 'makeObserved'; export const ARKUI_STATE_MANAGEMENT = '@ohos.arkui.StateManagement'; +export const NEW_PROP_DECORATOR_SUFFIX = 'Ref'; export enum CustomDecoratorName { Extend = 'Extend', @@ -33,7 +34,7 @@ export enum CustomDecoratorName { AnimatableExtend = 'AnimatableExtend', Memo = 'Memo', Observed = 'Observed', - Layoutable = 'Layoutable' + CustomLayout = 'CustomLayout' } export enum StorageTypeName { @@ -70,7 +71,10 @@ export const skipImportDecoratorName: Set = new Set([ 'Styles', 'Sendable', 'Concurrent', - 'LocalBuilder' + 'LocalBuilder', + 'Prop', + 'StorageProp', + 'LocalStorageProp' ]); export const customLayoutFunctionName: Set = new Set(['onMeasureSize', 'onPlaceChildren']); diff --git a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts index 2a9e201f68677de4bd209cb995da5008d0fd849d..3adcc10ab53b75ec891144762a4ee0863c043e63 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkuiImportList.ts @@ -262,6 +262,7 @@ export const arkuiImportList: Set = new Set([ 'CrownSensitivity', 'CurrentDayStyle', 'Curve', + 'CustomLayout', 'CustomBuilder', 'CustomComponent', 'CustomComponentV2', @@ -687,6 +688,7 @@ export const arkuiImportList: Set = new Set([ 'LocalStorage', 'LocalStorageLink', 'LocalStorageProp', + 'LocalStoragePropRef', 'LocalizedAlignRuleOptions', 'LocalizedAlignment', 'LocalizedBarrierDirection', @@ -1054,6 +1056,7 @@ export const arkuiImportList: Set = new Set([ 'ProgressStyleOptions', 'ProgressType', 'Prop', + 'PropRef', 'ProtectedResourceType', 'Provide', 'ProvideOptions', @@ -1100,6 +1103,7 @@ export const arkuiImportList: Set = new Set([ 'RenderProcessNotRespondingData', 'RenderProcessNotRespondingReason', 'RenderingContextSettings', + 'Repeat', 'RepeatAttribute', 'RepeatItem', 'RepeatMode', @@ -1321,6 +1325,7 @@ export const arkuiImportList: Set = new Set([ 'Storage', 'StorageLink', 'StorageProp', + 'StoragePropRef', 'StyleOptions', 'StyledString', 'StyledStringChangeValue', diff --git a/ets2panda/linter/src/lib/utils/consts/ArraysAPI.ts b/ets2panda/linter/src/lib/utils/consts/ArraysAPI.ts new file mode 100755 index 0000000000000000000000000000000000000000..4076fa0f93eda6dcd88b276bd66ccbd122e3d704 --- /dev/null +++ b/ets2panda/linter/src/lib/utils/consts/ArraysAPI.ts @@ -0,0 +1,49 @@ +/* + * 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 const ARRAY_API_LIST = [ + 'length', + 'concat', + 'copyWithin', + 'entries', + 'every', + 'fill', + 'filter', + 'find', + 'findIndex', + 'flat', + 'flatMap', + 'forEach', + 'includes', + 'indexOf', + 'join', + 'keys', + 'lastIndexOf', + 'map', + 'pop', + 'push', + 'reduce', + 'reduceRight', + 'reverse', + 'shift', + 'slice', + 'some', + 'sort', + 'splice', + 'toLocaleString', + 'toString', + 'unshift', + 'values' +]; diff --git a/ets2panda/linter/src/lib/utils/consts/AssociatedInfo.ts b/ets2panda/linter/src/lib/utils/consts/AssociatedInfo.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c3409d7ce7b8ac80d9a3931cb5019bc7e44d6dd --- /dev/null +++ b/ets2panda/linter/src/lib/utils/consts/AssociatedInfo.ts @@ -0,0 +1,22 @@ +/* + * 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 { FaultID } from '../../Problems'; +import { SdkProblem } from './SdkWhitelist'; + +export const globalApiAssociatedInfo: Map = new Map([ + [SdkProblem.DeclWithDuplicateName, FaultID.DuplicateDeclNameFromSdk], + [SdkProblem.LimitedVoidType, FaultID.LimitedVoidTypeFromSdk] +]); diff --git a/ets2panda/linter/test/main/debugger_statememt.ets.migrate.ets b/ets2panda/linter/src/lib/utils/consts/ErrorProp.ts similarity index 85% rename from ets2panda/linter/test/main/debugger_statememt.ets.migrate.ets rename to ets2panda/linter/src/lib/utils/consts/ErrorProp.ts index 04eeeb8969692e0bcd2becb26ad2df9437c05370..ce654970620ba7e86c8499b78e79627f440ce790 100644 --- a/ets2panda/linter/test/main/debugger_statememt.ets.migrate.ets +++ b/ets2panda/linter/src/lib/utils/consts/ErrorProp.ts @@ -13,10 +13,4 @@ * limitations under the License. */ -specialAutofixLib.debugger(); - -function a() { - specialAutofixLib.debugger(); -} - -console.log('debugger'); \ No newline at end of file +export const ERROR_PROP_LIST: Set = new Set(['name', 'message', 'stack', 'code']); diff --git a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts index c3566b66db6a4acb482811cfb3857b8fdc716f61..285a75b407baf65f6c5d0096832041ebf3dc57c0 100644 --- a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts @@ -12,14 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import type * as ts from 'typescript'; -export const USE_STATIC = '\'use static\''; export const ARE_EQUAL = 'areEqual'; export const ARE_STRICTLY_EQUAL = 'areStrictlyEqual'; export const WRAP = 'wrap'; export const INSTANTIATE = 'instantiate'; +export const LENGTH = 'length'; export const INVOKE = 'invoke'; export const INVOKE_METHOD = 'invokeMethod'; +export const TO_PROMISE = 'toPromise'; +export const IS_INSTANCE_OF = 'isInstanceOf'; export const REFLECT_PROPERTIES = [ 'get', @@ -56,6 +59,8 @@ export const OBJECT_PROPERTIES = [ 'isFrozen', 'isSealed' ]; + +export const USE_STATIC = '\'use static\''; export const OBJECT_LITERAL = 'Object'; export const REFLECT_LITERAL = 'Reflect'; export const NONE = 'none'; @@ -73,3 +78,13 @@ export enum InteropType { LEGACY = '1.0', NONE = 'none' } + +export type IdentifierAndArguments = { + ident: undefined | ts.Identifier; + args: ts.NodeArray | undefined; +}; + +export type IncrementDecrementNodeInfo = { + varAssignText: string; + addOrDecrOperation: ts.BinaryExpression; +}; diff --git a/ets2panda/linter/src/lib/utils/consts/RuntimeCheckAPI.ts b/ets2panda/linter/src/lib/utils/consts/RuntimeCheckAPI.ts index 9fa38ab9fa8dabf173ef922af4e83eb50264daad..738c2b187280a58d968e7a35ae63b8ffa4cd8a0b 100644 --- a/ets2panda/linter/src/lib/utils/consts/RuntimeCheckAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/RuntimeCheckAPI.ts @@ -17,7 +17,7 @@ import type ts from 'typescript'; export type ArrayAccess = { pos: number; - accessingIdentifier: 'number' | ts.Identifier; + accessingIdentifier: 'number' | ts.Identifier | ts.Expression; arrayIdent: ts.Identifier; }; diff --git a/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.arkts2.json b/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.arkts2.json index 36254158540286646fc21063b6b306396f132eb7..2a6b56517a1405887a664ab9dc3192310aed2963 100755 --- a/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.arkts2.json +++ b/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.arkts2.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 56, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 17, "column": 40, diff --git a/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.json b/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.json index 8af4f78669b31c787e4cd40ae005aff560769df3..28c397d84b60c01802aa10c57ae051b20a183e7c 100755 --- a/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.json +++ b/ets2panda/linter/test/builtin/builtin_symbol_iterator.ets.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 56, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/@ohos.taskpool.ets b/ets2panda/linter/test/concurrent/@ohos.taskpool.ets new file mode 100755 index 0000000000000000000000000000000000000000..52a0d01da6b39a975c7146f9c643c5191fb19105 --- /dev/null +++ b/ets2panda/linter/test/concurrent/@ohos.taskpool.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +type func = ()=>void +export namespace taskpool{ + export function isConcurrent(param:func):boolean { + return true + } +} +export namespace otherTaskPool{ + export function isConcurrent(param:func):boolean { + return true + } +} diff --git a/ets2panda/linter/test/concurrent/@ohos.taskpool.ets.args.json b/ets2panda/linter/test/concurrent/@ohos.taskpool.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..0adede204e309a92c8aac08d89f6af16d9c93f78 --- /dev/null +++ b/ets2panda/linter/test/concurrent/@ohos.taskpool.ets.args.json @@ -0,0 +1,18 @@ +{ + "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": { + } +} diff --git a/ets2panda/linter/test/concurrent/@ohos.taskpool.ets.json b/ets2panda/linter/test/concurrent/@ohos.taskpool.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/concurrent/@ohos.taskpool.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets new file mode 100755 index 0000000000000000000000000000000000000000..a0e9c55367f1546d3e120937ca8372b2473fef37 --- /dev/null +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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 { SharedArrayBuffer } from './oh_modules/sharedArrayBuffer' + +let s1 = new SharedArrayBuffer(1) //lib.es2017.sharedmemory.d.ts +s1.slice(0) +type sharedArray = SharedArrayBuffer +let s2: sharedArray; +type mapShare = Map +{ + let s1 = new SharedArrayBuffer(1) //lib.es2017.sharedmemory.d.ts + let s2:sharedArray; +} +function fun6(pa:sharedArray) { + let s1 = new SharedArrayBuffer(1) //lib.es2017.sharedmemory.d.ts + let s2:sharedArray; +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.args.json b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..3318ebbbcfd0ce90dc5f69df69452a3201e4204d --- /dev/null +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.arkts2.json b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..ccc21ad852817e879704bf730636157c56c9016e --- /dev/null +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.arkts2.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 17, + "column": 32, + "endLine": 17, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 10, + "endLine": 18, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 34, + "endLine": 23, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 34, + "endLine": 27, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.autofix.json b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.autofix.json new file mode 100755 index 0000000000000000000000000000000000000000..bb890b9c3b90f345391be21fda2a5eb236ee6799 --- /dev/null +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.autofix.json @@ -0,0 +1,102 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 17, + "column": 32, + "endLine": 17, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 724, + "end": 725, + "replacementText": "1.0", + "line": 17, + "column": 32, + "endLine": 17, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 10, + "endLine": 18, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 769, + "end": 770, + "replacementText": "0.0", + "line": 18, + "column": 10, + "endLine": 18, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 34, + "endLine": 23, + "endColumn": 35, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 917, + "end": 918, + "replacementText": "1.0", + "line": 23, + "column": 34, + "endLine": 23, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 34, + "endLine": 27, + "endColumn": 35, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1044, + "end": 1045, + "replacementText": "1.0", + "line": 27, + "column": 34, + "endLine": 27, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.json b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..fae7c2a3fe332707886d01e70ea981341f927c59 --- /dev/null +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.migrate.ets b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.migrate.ets new file mode 100755 index 0000000000000000000000000000000000000000..9854ff55652fd3b6e96c5b6d2fa75d9eead0aa8a --- /dev/null +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.migrate.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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 { SharedArrayBuffer } from './oh_modules/sharedArrayBuffer' + +let s1 = new SharedArrayBuffer(1.0) //lib.es2017.sharedmemory.d.ts +s1.slice(0.0) +type sharedArray = SharedArrayBuffer +let s2: sharedArray; +type mapShare = Map +{ + let s1 = new SharedArrayBuffer(1.0) //lib.es2017.sharedmemory.d.ts + let s2:sharedArray; +} +function fun6(pa:sharedArray) { + let s1 = new SharedArrayBuffer(1.0) //lib.es2017.sharedmemory.d.ts + let s2:sharedArray; +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.migrate.json b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.migrate.json new file mode 100755 index 0000000000000000000000000000000000000000..95e6d40d6a3afa83ed578df1b91fe6ad710455e3 --- /dev/null +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer1_arkts2.ets.migrate.json @@ -0,0 +1,3 @@ +{ + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets index d3e0b2ca58ad6fde6ac4d5ba2e1d5e38bafd84a0..b6c511a7ad6194f0e29ea43ba3fa1b6843bcd5ca 100644 --- a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets @@ -21,4 +21,10 @@ let newTypeName: NewTypeName // disable use new NewTypeName() let ntn: NewTypeName = new SharedArrayBuffer(0) // ERROR -function foo(atmo: Atomics) {} // NOT ERROR \ No newline at end of file +function foo(atmo: Atomics) {} // NOT ERROR + +class A extends SharedArrayBuffer { + constructor() { + supper(1) + } +} diff --git a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.arkts2.json b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.arkts2.json index fa8024c8d379432c1df90cff56452f46adf572b1..c390c26562aab76528f553635f51e1d1fd6a142f 100644 --- a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.arkts2.json +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.arkts2.json @@ -83,6 +83,26 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 26, + "column": 17, + "endLine": 26, + "endColumn": 34, + "problem": "SharedArrayBufferDeprecated", + "suggest": "", + "rule": "SharedArrayBuffer is not supported (arkts-no-need-stdlib-sharedArrayBuffer)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 16, + "endLine": 28, + "endColumn": 17, + "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/concurrent/concurrent_sharedarraybuffer_arkts2.ets.autofix.json b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.autofix.json index 01e6621c9d4fa857cd90d0c8cf61deab97cebef2..4eea7766a3ba34154a8dff0dd467b21b54e53e37 100644 --- a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "SharedArrayBufferDeprecated", "autofix": [ { - "replacementText": "ArrayBuffer", "start": 624, "end": 641, + "replacementText": "ArrayBuffer", "line": 16, "column": 15, "endLine": 16, @@ -43,9 +43,9 @@ "problem": "SharedArrayBufferDeprecated", "autofix": [ { - "replacementText": "ArrayBuffer", "start": 661, "end": 678, + "replacementText": "ArrayBuffer", "line": 17, "column": 10, "endLine": 17, @@ -64,9 +64,9 @@ "problem": "SharedArrayBufferDeprecated", "autofix": [ { - "replacementText": "ArrayBuffer", "start": 685, "end": 702, + "replacementText": "ArrayBuffer", "line": 17, "column": 34, "endLine": 17, @@ -106,9 +106,9 @@ "problem": "SharedArrayBufferDeprecated", "autofix": [ { - "replacementText": "ArrayBuffer", "start": 737, "end": 754, + "replacementText": "ArrayBuffer", "line": 19, "column": 20, "endLine": 19, @@ -127,9 +127,9 @@ "problem": "SharedArrayBufferDeprecated", "autofix": [ { - "replacementText": "ArrayBuffer", "start": 853, "end": 870, + "replacementText": "ArrayBuffer", "line": 22, "column": 28, "endLine": 22, @@ -160,6 +160,48 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 26, + "column": 17, + "endLine": 26, + "endColumn": 34, + "problem": "SharedArrayBufferDeprecated", + "autofix": [ + { + "start": 945, + "end": 962, + "replacementText": "ArrayBuffer", + "line": 26, + "column": 17, + "endLine": 26, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "SharedArrayBuffer is not supported (arkts-no-need-stdlib-sharedArrayBuffer)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 16, + "endLine": 28, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1000, + "end": 1001, + "replacementText": "1.0", + "line": 28, + "column": 16, + "endLine": 28, + "endColumn": 17 + } + ], + "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/concurrent/concurrent_sharedarraybuffer_arkts2.ets.migrate.ets b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.migrate.ets index 7a393ab10fe816bdd7c0aac6177253fc60e97e4a..b7e398fb0a3d46ac7404e6732e59adc890b68ad0 100644 --- a/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.migrate.ets +++ b/ets2panda/linter/test/concurrent/concurrent_sharedarraybuffer_arkts2.ets.migrate.ets @@ -21,4 +21,10 @@ let newTypeName: NewTypeName // disable use new NewTypeName() let ntn: NewTypeName = new ArrayBuffer(0.0) // ERROR -function foo(atmo: Atomics) {} // NOT ERROR \ No newline at end of file +function foo(atmo: Atomics) {} // NOT ERROR + +class A extends ArrayBuffer { + constructor() { + supper(1.0) + } +} diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json b/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json index ca28292f8e4d54b3a473114b5d2238f3fa55c03f..428032b2d86c83a7b126a00d005a4c9cc028e644 100644 --- a/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent.ets.arkts2.json @@ -15,24 +15,14 @@ ], "result": [ { - "line": 23, - "column": 32, - "endLine": 23, - "endColumn": 44, - "problem": "IsConcurrentDeprecated", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 12, + "problem": "LimitedStdLibNoDoncurrentDecorator", "suggest": "", - "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 27, - "endLine": 25, - "endColumn": 39, - "problem": "IsConcurrentDeprecated", - "suggest": "", - "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-concurrent-decorator)", "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets new file mode 100755 index 0000000000000000000000000000000000000000..2db768e0e8304c82051608308777fe918f3c97c6 --- /dev/null +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets @@ -0,0 +1,42 @@ +/* + * 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 { taskpool } from '@ohos.taskpool'; +import { taskpool as taskpool2 } from './@ohos.taskpool'; +import { otherTaskPool as taskpool1 } from './@ohos.taskpool'; + +function test1(){ +} +function isConcurrent() {} + +typeof taskpool.isConcurrent() ; //error +function test(){ + taskpool.isConcurrent(test5()) ; //error +} + +console.log(''+taskpool2.isConcurrent(test1)); + +taskpool2.isConcurrent(test1) +taskpool2.isConcurrent(test1) +taskpool2.isConcurrent(isConcurrent) +function test5(){ + taskpool2.isConcurrent(test1) + taskpool2.isConcurrent(test1) + taskpool2.isConcurrent(isConcurrent) +} +class Demo{ + get(){ + return taskpool1.isConcurrent(test); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.args.json b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..e2b903f0aa82e6ca4108ff67d5272bf49d6c2a5b --- /dev/null +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.args.json @@ -0,0 +1,19 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "" + } + } \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..b418f42b2130a303f51785ae4ec7b67abd0a67b4 --- /dev/null +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.arkts2.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 43, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 17, + "endLine": 23, + "endColumn": 29, + "problem": "IsConcurrentDeprecated", + "suggest": "", + "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 12, + "endLine": 25, + "endColumn": 24, + "problem": "IsConcurrentDeprecated", + "suggest": "", + "rule": "isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 32, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.json b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..b9331d05ba1f182a8a451c219c9e51bcd4e67188 --- /dev/null +++ b/ets2panda/linter/test/concurrent/no_support_isconcurrent2.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] + } \ No newline at end of file diff --git a/ets2panda/linter/test/concurrent/oh_modules/sharedArrayBuffer.ts b/ets2panda/linter/test/concurrent/oh_modules/sharedArrayBuffer.ts new file mode 100755 index 0000000000000000000000000000000000000000..cc5c84462f2a1a18a5f3644c13742d25b878daa7 --- /dev/null +++ b/ets2panda/linter/test/concurrent/oh_modules/sharedArrayBuffer.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023-2024 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. + */ +// oh_modules/sharedArrayBuffer.ts +export interface SharedArrayBuffer { + /** + * Read-only. The length of the ArrayBuffer (in bytes). + */ + readonly byteLength: number; + +/** + * Returns a section of an SharedArrayBuffer. + */ + slice(begin: number, end?: number): SharedArrayBuffer; +} +interface SharedArrayBufferConstructor { + readonly prototype: SharedArrayBuffer; + new (byteLength: number): SharedArrayBuffer; +} +export declare var SharedArrayBuffer: SharedArrayBufferConstructor; + diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets b/ets2panda/linter/test/interop/binary_operation_js_obj.ets old mode 100755 new mode 100644 index 29bfa417e57a9375c0c37fa471bf0fa9b52f0080..472ad5669d75bba44ac209e2e148c3b4570a1a0e --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets @@ -12,8 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' -import {foo} from "./binary_operation_js_obj_js" +import {foo,m,n} from "./binary_operation_js_obj_js" let a = foo.a let b = foo.b a + b @@ -21,4 +20,24 @@ a - b a * b a / b a % b -a ** b \ No newline at end of file +a ** b + +m + n +m % n +m ** n + +let x = 1, y = 2; +x + y; +x - y; +x % y; +x ** y; + +let bar = { a: 1, b: 2 }; + +let x2 = bar.a, y2 = bar.b; +x2 + y2; +x2 - y2; +x2 % y2; +x2 ** y2; + +foo.a + foo.b; \ No newline at end of file diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.args.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.args.json index 3318ebbbcfd0ce90dc5f69df69452a3201e4204d..b13bb90d5b5f6d3dc5f0d054663eeba637fcc7dd 100755 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.args.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.args.json @@ -1,21 +1,21 @@ -{ - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "mode": { - "arkts2": "", - "autofix": "--arkts-2", - "migrate": "--arkts-2" - } -} +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.arkts2.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.arkts2.json old mode 100755 new mode 100644 index f069ac9eeb23b6d2519c4392de77121237d91a2f..6734ea601860e570b16353085ab2dddd748c54d2 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.arkts2.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.arkts2.json @@ -15,29 +15,19 @@ ], "result": [ { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 49, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 16, + "line": 15, "column": 1, - "endLine": 16, - "endColumn": 49, + "endLine": 15, + "endColumn": 53, "problem": "InterOpImportJs", "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 9, - "endLine": 17, + "endLine": 16, "endColumn": 14, "problem": "InteropObjectProperty", "suggest": "", @@ -49,29 +39,29 @@ "column": 9, "endLine": 17, "endColumn": 14, - "problem": "InteropJsObjectUsage", + "problem": "InteropObjectProperty", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { "line": 18, - "column": 9, + "column": 1, "endLine": 18, - "endColumn": 14, - "problem": "InteropObjectProperty", + "endColumn": 2, + "problem": "BinaryOperations", "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { "line": 18, - "column": 9, + "column": 5, "endLine": 18, - "endColumn": 14, - "problem": "InteropJsObjectUsage", + "endColumn": 6, + "problem": "BinaryOperations", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { @@ -166,8 +156,58 @@ }, { "line": 23, - "column": 5, + "column": 6, + "endLine": 23, + "endColumn": 7, + "problem": "BinaryOperations", + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 3, "endLine": 23, + "endColumn": 5, + "problem": "ExponentOp", + "suggest": "", + "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 2, + "problem": "BinaryOperations", + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 6, + "problem": "BinaryOperations", + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 2, + "problem": "BinaryOperations", + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, "endColumn": 6, "problem": "BinaryOperations", "suggest": "", @@ -175,9 +215,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 27, "column": 1, - "endLine": 24, + "endLine": 27, "endColumn": 2, "problem": "BinaryOperations", "suggest": "", @@ -185,9 +225,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 27, "column": 6, - "endLine": 24, + "endLine": 27, "endColumn": 7, "problem": "BinaryOperations", "suggest": "", @@ -195,14 +235,164 @@ "severity": "ERROR" }, { - "line": 24, + "line": 27, "column": 3, - "endLine": 24, + "endLine": 27, "endColumn": 5, "problem": "ExponentOp", "suggest": "", "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 9, + "endLine": 29, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 12, + "endLine": 29, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 3, + "endLine": 33, + "endColumn": 5, + "problem": "ExponentOp", + "suggest": "", + "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 16, + "endLine": 35, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 22, + "endLine": 35, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 17, + "endLine": 37, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 4, + "endLine": 41, + "endColumn": 6, + "problem": "ExponentOp", + "suggest": "", + "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6, + "problem": "BinaryOperations", + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14, + "problem": "BinaryOperations", + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json old mode 100755 new mode 100644 index 18043cd8a08542f8160a583dfa44dbd06ee190d6..8bf1b635a68ff6b9b200e96005430d8081c31da9 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json @@ -13,41 +13,31 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ +"result": [ { - "line": 16, + "line": 15, "column": 1, - "endLine": 16, - "endColumn": 49, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 49, + "endLine": 15, + "endColumn": 53, "problem": "InterOpImportJs", "autofix": [ { - "start": 617, - "end": 665, + "start": 604, + "end": 656, "replacementText": "", - "line": 16, + "line": 15, "column": 1, - "endLine": 16, - "endColumn": 49 + "endLine": 15, + "endColumn": 53 }, { - "start": 665, - "end": 665, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./binary_operation_js_obj_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n", - "line": 16, + "start": 656, + "end": 656, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./binary_operation_js_obj_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\nlet m = GeneratedImportVar_1.getPropertyByName('m');\nlet n = GeneratedImportVar_1.getPropertyByName('n');\n", + "line": 15, "column": 1, - "endLine": 16, - "endColumn": 49 + "endLine": 15, + "endColumn": 53 } ], "suggest": "", @@ -55,19 +45,19 @@ "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 9, - "endLine": 17, + "endLine": 16, "endColumn": 14, "problem": "InteropObjectProperty", "autofix": [ { - "start": 674, - "end": 679, + "start": 665, + "end": 670, "replacementText": "foo.getPropertyByName(\"a\")", - "line": 17, + "line": 16, "column": 9, - "endLine": 17, + "endLine": 16, "endColumn": 14 } ], @@ -80,12 +70,12 @@ "column": 9, "endLine": 17, "endColumn": 14, - "problem": "InteropJsObjectUsage", + "problem": "InteropObjectProperty", "autofix": [ { - "replacementText": "foo.getPropertyByName('a').toNumber()", - "start": 674, - "end": 679, + "start": 679, + "end": 684, + "replacementText": "foo.getPropertyByName(\"b\")", "line": 17, "column": 9, "endLine": 17, @@ -93,49 +83,49 @@ } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { "line": 18, - "column": 9, + "column": 1, "endLine": 18, - "endColumn": 14, - "problem": "InteropObjectProperty", + "endColumn": 2, + "problem": "BinaryOperations", "autofix": [ { - "start": 688, - "end": 693, - "replacementText": "foo.getPropertyByName(\"b\")", + "start": 665, + "end": 670, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", "line": 18, - "column": 9, + "column": 1, "endLine": 18, - "endColumn": 14 + "endColumn": 2 } ], "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { "line": 18, - "column": 9, + "column": 5, "endLine": 18, - "endColumn": 14, - "problem": "InteropJsObjectUsage", + "endColumn": 6, + "problem": "BinaryOperations", "autofix": [ { - "replacementText": "foo.getPropertyByName('b').toNumber()", - "start": 688, - "end": 693, + "start": 679, + "end": 684, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", "line": 18, - "column": 9, + "column": 5, "endLine": 18, - "endColumn": 14 + "endColumn": 6 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { @@ -144,6 +134,17 @@ "endLine": 19, "endColumn": 2, "problem": "BinaryOperations", + "autofix": [ + { + "start": 665, + "end": 670, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 2 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -154,6 +155,17 @@ "endLine": 19, "endColumn": 6, "problem": "BinaryOperations", + "autofix": [ + { + "start": 679, + "end": 684, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 6 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -164,6 +176,17 @@ "endLine": 20, "endColumn": 2, "problem": "BinaryOperations", + "autofix": [ + { + "start": 665, + "end": 670, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 2 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -174,6 +197,17 @@ "endLine": 20, "endColumn": 6, "problem": "BinaryOperations", + "autofix": [ + { + "start": 679, + "end": 684, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 6 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -184,6 +218,17 @@ "endLine": 21, "endColumn": 2, "problem": "BinaryOperations", + "autofix": [ + { + "start": 665, + "end": 670, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 2 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -194,6 +239,17 @@ "endLine": 21, "endColumn": 6, "problem": "BinaryOperations", + "autofix": [ + { + "start": 679, + "end": 684, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 6 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -204,6 +260,17 @@ "endLine": 22, "endColumn": 2, "problem": "BinaryOperations", + "autofix": [ + { + "start": 665, + "end": 670, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 2 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -214,6 +281,17 @@ "endLine": 22, "endColumn": 6, "problem": "BinaryOperations", + "autofix": [ + { + "start": 679, + "end": 684, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 6 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" @@ -224,60 +302,533 @@ "endLine": 23, "endColumn": 2, "problem": "BinaryOperations", + "autofix": [ + { + "start": 665, + "end": 670, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 2 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { "line": 23, - "column": 5, + "column": 6, + "endLine": 23, + "endColumn": 7, + "problem": "BinaryOperations", + "autofix": [ + { + "start": 679, + "end": 684, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 23, + "column": 6, + "endLine": 23, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 3, "endLine": 23, + "endColumn": 5, + "problem": "ExponentOp", + "autofix": [ + { + "replacementText": "Math.pow(a, b)", + "start": 715, + "end": 721, + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 2, + "problem": "BinaryOperations", + "autofix": [ + { + "start": 723, + "end": 724, + "replacementText": "m.toNumber()", + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, "endColumn": 6, "problem": "BinaryOperations", + "autofix": [ + { + "start": 727, + "end": 728, + "replacementText": "n.toNumber()", + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 6 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { - "line": 24, + "line": 26, "column": 1, - "endLine": 24, + "endLine": 26, "endColumn": 2, "problem": "BinaryOperations", + "autofix": [ + { + "start": 729, + "end": 730, + "replacementText": "m.toNumber()", + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 6, + "problem": "BinaryOperations", + "autofix": [ + { + "start": 733, + "end": 734, + "replacementText": "n.toNumber()", + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 6 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { - "line": 24, + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 2, + "problem": "BinaryOperations", + "autofix": [ + { + "start": 735, + "end": 736, + "replacementText": "m.toNumber()", + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 27, "column": 6, - "endLine": 24, + "endLine": 27, "endColumn": 7, "problem": "BinaryOperations", + "autofix": [ + { + "start": 740, + "end": 741, + "replacementText": "n.toNumber()", + "line": 27, + "column": 6, + "endLine": 27, + "endColumn": 7 + } + ], "suggest": "", "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", "severity": "ERROR" }, { - "line": 24, + "line": 27, "column": 3, - "endLine": 24, + "endLine": 27, "endColumn": 5, "problem": "ExponentOp", "autofix": [ { - "replacementText": "Math.pow(a, b)", - "start": 724, - "end": 730, - "line": 24, + "replacementText": "Math.pow(m, n)", + "start": 735, + "end": 741, + "line": 27, + "column": 3, + "endLine": 27, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 747, + "end": 752, + "replacementText": "x: number = 1", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 9, + "endLine": 29, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 751, + "end": 752, + "replacementText": "1.0", + "line": 29, + "column": 9, + "endLine": 29, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 12, + "endLine": 29, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 754, + "end": 759, + "replacementText": "y: number = 2", + "line": 29, + "column": 12, + "endLine": 29, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 758, + "end": 759, + "replacementText": "2.0", + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 3, + "endLine": 33, + "endColumn": 5, + "problem": "ExponentOp", + "autofix": [ + { + "replacementText": "Math.pow(x, y)", + "start": 782, + "end": 788, + "line": 33, "column": 3, - "endLine": 24, + "endLine": 33, "endColumn": 5 } ], "suggest": "", "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", "severity": "ERROR" + }, + { + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12, + "problem": "ObjectLiteralNoContextType", + "autofix": [ + { + "start": 791, + "end": 791, + "replacementText": "interface GeneratedObjectLiteralInterface_1 {\n a: number;\n b: number;\n}\n", + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12 + }, + { + "start": 798, + "end": 798, + "replacementText": ": GeneratedObjectLiteralInterface_1", + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 16, + "endLine": 35, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 806, + "end": 807, + "replacementText": "1.0", + "line": 35, + "column": 16, + "endLine": 35, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 22, + "endLine": 35, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 812, + "end": 813, + "replacementText": "2.0", + "line": 35, + "column": 22, + "endLine": 35, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 822, + "end": 832, + "replacementText": "x2: number = bar.a", + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 17, + "endLine": 37, + "endColumn": 27, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 834, + "end": 844, + "replacementText": "y2: number = bar.b", + "line": 37, + "column": 17, + "endLine": 37, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 4, + "endLine": 41, + "endColumn": 6, + "problem": "ExponentOp", + "autofix": [ + { + "replacementText": "Math.pow(x2, y2)", + "start": 873, + "end": 881, + "line": 41, + "column": 4, + "endLine": 41, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "exponent opartions \"**\" and \"**=\" are disabled (arkts-no-exponent-op)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6, + "problem": "BinaryOperations", + "autofix": [ + { + "start": 884, + "end": 889, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14, + "problem": "BinaryOperations", + "autofix": [ + { + "start": 892, + "end": 897, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Binary operations on js objects (arkts-interop-js2s-binary-op)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 884, + "end": 889, + "replacementText": "foo.getPropertyByName(\"a\")", + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 892, + "end": 897, + "replacementText": "foo.getPropertyByName(\"b\")", + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.json index 24e48e6dcb622409f469756ff0b09fbb2879d9cc..e28baca176a2b17f328386775efec64717650b4b 100755 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.json @@ -15,13 +15,13 @@ ], "result": [ { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 49, - "problem": "ImportAfterStatement", + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12, + "problem": "ObjectLiteralNoContextType", "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets index 72c3c6c688c6661b162927589e92e506e543da91..f29b91c27508799b1f7054d1ab2b622b82fe51cd 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.ets @@ -12,9 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' let GeneratedImportVar_1 = ESValue.load('./binary_operation_js_obj_js'); let foo = GeneratedImportVar_1.getPropertyByName('foo'); +let m = GeneratedImportVar_1.getPropertyByName('m'); +let n = GeneratedImportVar_1.getPropertyByName('n'); let a = foo.getPropertyByName("a") let b = foo.getPropertyByName("b") @@ -23,4 +24,28 @@ a - b a * b a / b a % b -Math.pow(a, b) \ No newline at end of file +Math.pow(a, b) + +m.toNumber() + n.toNumber() +m.toNumber() % n.toNumber() +Math.pow(m.toNumber(), n.toNumber()) + +let x: number = 1.0, y: number = 2.0; +x + y; +x - y; +x % y; +Math.pow(x, y); + +interface GeneratedObjectLiteralInterface_1 { + a: number; + b: number; +} +let bar: GeneratedObjectLiteralInterface_1 = { a: 1.0, b: 2.0 }; + +let x2: number = bar.a, y2: number = bar.b; +x2 + y2; +x2 - y2; +x2 % y2; +Math.pow(x2, y2); + +foo.getPropertyByName("a").toNumber() + foo.getPropertyByName("b").toNumber(); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json index 2caa23e507419af4d11c9232fc89618c12ad92f1..817c2a94501ff9e7c7d318f8d8bacf6f388092a8 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.migrate.json @@ -14,11 +14,21 @@ "limitations under the License." ], "result": [ + { + "line": 15, + "column": 5, + "endLine": 15, + "endColumn": 72, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, { "line": 16, "column": 5, "endLine": 16, - "endColumn": 72, + "endColumn": 56, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -28,17 +38,17 @@ "line": 17, "column": 5, "endLine": 17, - "endColumn": 56, + "endColumn": 52, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 5, - "endLine": 19, - "endColumn": 35, + "endLine": 18, + "endColumn": 52, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -55,14 +65,54 @@ "severity": "ERROR" }, { - "line": 26, + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 15, + "problem": "MathPow", + "suggest": "", + "rule": "function \"Math.pow()\" behavior for ArkTS differs from Typescript version (arkts-math-pow-standard-diff)", + "severity": "ERROR" + }, + { + "line": 31, "column": 1, - "endLine": 26, + "endLine": 31, + "endColumn": 37, + "problem": "MathPow", + "suggest": "", + "rule": "function \"Math.pow()\" behavior for ArkTS differs from Typescript version (arkts-math-pow-standard-diff)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 1, + "endLine": 37, "endColumn": 15, "problem": "MathPow", "suggest": "", "rule": "function \"Math.pow()\" behavior for ArkTS differs from Typescript version (arkts-math-pow-standard-diff)", "severity": "ERROR" + }, + { + "line": 49, + "column": 1, + "endLine": 49, + "endColumn": 17, + "problem": "MathPow", + "suggest": "", + "rule": "function \"Math.pow()\" behavior for ArkTS differs from Typescript version (arkts-math-pow-standard-diff)", + "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj_js.js b/ets2panda/linter/test/interop/binary_operation_js_obj_js.js index aaf9c1dd4e9e4e7e46d0cf3efb92bb573817fde8..c8f9951bdacb9a6fd47ef3704d312293cb78ffd4 100755 --- a/ets2panda/linter/test/interop/binary_operation_js_obj_js.js +++ b/ets2panda/linter/test/interop/binary_operation_js_obj_js.js @@ -14,3 +14,5 @@ */ export let foo = {a: 1, b: 2} +export let m = 3 +export let n = 2 \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_function.ets b/ets2panda/linter/test/interop/call_function.ets index b76d862f4a67e010fbb3cd04176ba255c400dab8..74665b905caef883c904b8ee1d13c01b7efc4e0a 100644 --- a/ets2panda/linter/test/interop/call_function.ets +++ b/ets2panda/linter/test/interop/call_function.ets @@ -1,19 +1,18 @@ -/* - * 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. - */ -'use static' -import {foo,bar} from "./call_function_js" - -foo() +/* + * 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 {foo,bar} from "./call_function_js" + +foo() bar(123) \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_function.ets.arkts2.json b/ets2panda/linter/test/interop/call_function.ets.arkts2.json index ed940011235b6ccb492d75ad97bafe0ec9ff7cdd..66335fa504eb461da8ade9c2cc71a8119f4e11f0 100644 --- a/ets2panda/linter/test/interop/call_function.ets.arkts2.json +++ b/ets2panda/linter/test/interop/call_function.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 16, + "line": 15, "column": 1, - "endLine": 16, - "endColumn": 43, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 16, - "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 43, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 1, - "endLine": 18, + "endLine": 17, "endColumn": 6, "problem": "CallJSFunction", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 9, "problem": "CallJSFunction", "suggest": "", @@ -55,9 +45,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 5, - "endLine": 19, + "endLine": 18, "endColumn": 8, "problem": "NumericSemantics", "suggest": "", diff --git a/ets2panda/linter/test/interop/call_function.ets.json b/ets2panda/linter/test/interop/call_function.ets.json index 08b4bd7b56c82c9eeb61e1bd092388f21bb9f59a..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/call_function.ets.json +++ b/ets2panda/linter/test/interop/call_function.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 43, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_object_methods.ets b/ets2panda/linter/test/interop/call_object_methods.ets index ee45f2bcf310af18a40e73daac122f063494253f..891ae57a57c60ed2252efb4a8f74c928702b2589 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets +++ b/ets2panda/linter/test/interop/call_object_methods.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' import { foo } from "./call_object_methods_js" foo.bar(123) diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.arkts2.json b/ets2panda/linter/test/interop/call_object_methods.ets.arkts2.json index d088101b49fff0479cfefc0586220ee0b8fbc083..92c91ccd5b6de9e797492192e27346ff5d953ddb 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.arkts2.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 16, + "line": 15, "column": 1, - "endLine": 16, - "endColumn": 47, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 16, - "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 47, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 1, - "endLine": 18, + "endLine": 17, "endColumn": 13, "problem": "InteropCallObjectMethods", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 9, - "endLine": 18, + "endLine": 17, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json b/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json index 85d3430d1725844bedd73cfcc4fb57b884650714..5776d747e91eb48f6601bcff75f5fe371e5f1e75 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.autofix.json @@ -15,38 +15,28 @@ ], "result": [ { - "line": 16, + "line": 15, "column": 1, - "endLine": 16, - "endColumn": 47, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 16, - "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 47, "problem": "InterOpImportJs", "autofix": [ { - "start": 617, - "end": 663, + "start": 604, + "end": 650, "replacementText": "", - "line": 16, + "line": 15, "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 47 }, { - "start": 663, - "end": 663, + "start": 650, + "end": 650, "replacementText": "let GeneratedImportVar_1 = ESValue.load('./call_object_methods_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n", - "line": 16, + "line": 15, "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 47 } ], @@ -55,36 +45,40 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 1, - "endLine": 18, + "endLine": 17, "endColumn": 13, "problem": "InteropCallObjectMethods", "autofix": [ - { - "start": 665, - "end": 677, - "replacementText": "foo.invokeMethod(\"bar\", ESValue.wrap(123))" - } + { + "start": 652, + "end": 664, + "replacementText": "foo.invokeMethod(\"bar\", ESValue.wrap(123))", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 13 + } ], "suggest": "", "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 9, - "endLine": 18, + "endLine": 17, "endColumn": 12, "problem": "NumericSemantics", "autofix": [ { - "start": 673, - "end": 676, + "start": 660, + "end": 663, "replacementText": "123.0", - "line": 18, + "line": 17, "column": 9, - "endLine": 18, + "endLine": 17, "endColumn": 12 } ], @@ -93,4 +87,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.json b/ets2panda/linter/test/interop/call_object_methods.ets.json index 8866623ce527a677439958b81b87b48a69851ee5..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 47, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets index aeed85e3005d17573e9aff15dc9b681399b58f3f..2d455bda8efef122fba489a3d60a57d3f71c6379 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets +++ b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' let GeneratedImportVar_1 = ESValue.load('./call_object_methods_js'); let foo = GeneratedImportVar_1.getPropertyByName('foo'); diff --git a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json index 5399cc769ed6721762185bea9cbc142c2fc048fb..4f96146af19c8bb188c5157221d11ba6cf249284 100644 --- a/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json +++ b/ets2panda/linter/test/interop/call_object_methods.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 16, + "line": 15, "column": 5, - "endLine": 16, + "endLine": 15, "endColumn": 68, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 5, - "endLine": 17, + "endLine": 16, "endColumn": 56, "problem": "AnyType", "suggest": "", @@ -35,4 +35,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets old mode 100755 new mode 100644 index e1d4d726e42ed9cf3f7fa79d50e53f253d739e58..9d1ec94c5645af3a80526bed72513c2abe775a6b --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets @@ -12,10 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' import {foo} from "./increases_decreases_js_obj_js" let a: number =0 a = foo.num++ a = ++foo.num a = foo.num-- a = --foo.num + +foo.num++ +++foo.num +foo.num-- +--foo.num diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.args.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.args.json index 3318ebbbcfd0ce90dc5f69df69452a3201e4204d..571ee6bb76b0cad72a9443db47c2f9d7db474bd0 100755 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.args.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.args.json @@ -1,21 +1,21 @@ -{ - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "mode": { - "arkts2": "", - "autofix": "--arkts-2", - "migrate": "--arkts-2" - } -} +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.arkts2.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.arkts2.json old mode 100755 new mode 100644 index 5e29c71a76559ae730740cb0b5a9e50a74732c6a..20513d8aadfe64b7b17b4d954a458946d60ab978 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.arkts2.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 52, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 16, + "line": 15, "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 52, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 16, - "endLine": 17, + "endLine": 16, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 14, "problem": "InteropIncrementDecrement", "suggest": "", @@ -55,9 +45,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 12, "problem": "InteropObjectProperty", "suggest": "", @@ -68,10 +58,20 @@ "line": 18, "column": 5, "endLine": 18, - "endColumn": 12, - "problem": "InteropJsObjectUsage", + "endColumn": 14, + "problem": "InteropIncrementDecrement", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 7, + "endLine": 18, + "endColumn": 14, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { @@ -86,83 +86,113 @@ }, { "line": 19, - "column": 7, + "column": 5, "endLine": 19, - "endColumn": 14, + "endColumn": 12, "problem": "InteropObjectProperty", "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { - "line": 19, - "column": 7, - "endLine": 19, + "line": 20, + "column": 5, + "endLine": 20, "endColumn": 14, - "problem": "InteropJsObjectUsage", + "problem": "InteropIncrementDecrement", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { "line": 20, - "column": 5, + "column": 7, "endLine": 20, "endColumn": 14, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 10, "problem": "InteropIncrementDecrement", "suggest": "", "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 12, + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 8, "problem": "InteropObjectProperty", "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 12, - "problem": "InteropJsObjectUsage", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 10, + "problem": "InteropIncrementDecrement", + "suggest": "", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 10, + "problem": "InteropObjectProperty", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 14, + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 10, "problem": "InteropIncrementDecrement", "suggest": "", "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { - "line": 21, - "column": 7, - "endLine": 21, - "endColumn": 14, + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 8, "problem": "InteropObjectProperty", "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { - "line": 21, - "column": 7, - "endLine": 21, - "endColumn": 14, - "problem": "InteropJsObjectUsage", + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 10, + "problem": "InteropIncrementDecrement", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 3, + "endLine": 25, + "endColumn": 10, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json old mode 100755 new mode 100644 index 06540703433696ac72e8700e6d11d7e7924f05b5..e48a8565b9797a819a48576450a0c1ddaf2d4b5d --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json @@ -14,39 +14,29 @@ "limitations under the License." ], "result": [ - { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 52, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 16, + { + "line": 15, "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 52, "problem": "InterOpImportJs", "autofix": [ { - "start": 617, - "end": 668, + "start": 604, + "end": 655, "replacementText": "", - "line": 16, + "line": 15, "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 52 }, { - "start": 668, - "end": 668, + "start": 655, + "end": 655, "replacementText": "let GeneratedImportVar_1 = ESValue.load('./increases_decreases_js_obj_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n", - "line": 16, + "line": 15, "column": 1, - "endLine": 16, + "endLine": 15, "endColumn": 52 } ], @@ -55,19 +45,19 @@ "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 16, - "endLine": 17, + "endLine": 16, "endColumn": 17, "problem": "NumericSemantics", "autofix": [ { - "start": 684, - "end": 685, + "start": 671, + "end": 672, "replacementText": "0.0", - "line": 17, + "line": 16, "column": 16, - "endLine": 17, + "endLine": 16, "endColumn": 17 } ], @@ -76,29 +66,40 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 14, "problem": "InteropIncrementDecrement", + "autofix": [ + { + "replacementText": "a = foo.getPropertyByName(\"num\").toNumber()\nfoo.setPropertyByName(num, a + 1)\na = a + 1\n", + "start": 673, + "end": 686, + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 14 + } + ], "suggest": "", "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 12, "problem": "InteropObjectProperty", "autofix": [ { - "start": 690, - "end": 697, + "start": 677, + "end": 684, "replacementText": "foo.getPropertyByName(\"num\")", - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 12 } ], @@ -110,73 +111,84 @@ "line": 18, "column": 5, "endLine": 18, - "endColumn": 12, - "problem": "InteropJsObjectUsage", + "endColumn": 14, + "problem": "InteropIncrementDecrement", "autofix": [ { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 690, - "end": 697, + "replacementText": "a = foo.getPropertyByName(\"num\").toNumber()\na = a + 1\nfoo.setPropertyByName(num, a)\n", + "start": 687, + "end": 700, "line": 18, "column": 5, "endLine": 18, - "endColumn": 12 + "endColumn": 14 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { - "line": 19, - "column": 5, - "endLine": 19, + "line": 18, + "column": 7, + "endLine": 18, "endColumn": 14, - "problem": "InteropIncrementDecrement", + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 693, + "end": 700, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 18, + "column": 7, + "endLine": 18, + "endColumn": 14 + } + ], "suggest": "", - "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { "line": 19, - "column": 7, + "column": 5, "endLine": 19, "endColumn": 14, - "problem": "InteropObjectProperty", + "problem": "InteropIncrementDecrement", "autofix": [ { - "start": 706, - "end": 713, - "replacementText": "foo.getPropertyByName(\"num\")", + "replacementText": "a = foo.getPropertyByName(\"num\").toNumber()\nfoo.setPropertyByName(num, a - 1)\na = a - 1\n", + "start": 701, + "end": 714, "line": 19, - "column": 7, + "column": 5, "endLine": 19, "endColumn": 14 } ], "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { "line": 19, - "column": 7, + "column": 5, "endLine": 19, - "endColumn": 14, - "problem": "InteropJsObjectUsage", + "endColumn": 12, + "problem": "InteropObjectProperty", "autofix": [ { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 706, - "end": 713, + "start": 705, + "end": 712, + "replacementText": "foo.getPropertyByName(\"num\")", "line": 19, - "column": 7, + "column": 5, "endLine": 19, - "endColumn": 14 + "endColumn": 12 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { @@ -185,25 +197,36 @@ "endLine": 20, "endColumn": 14, "problem": "InteropIncrementDecrement", + "autofix": [ + { + "replacementText": "a = foo.getPropertyByName(\"num\").toNumber()\na = a - 1\nfoo.setPropertyByName(num, a)\n", + "start": 715, + "end": 728, + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 14 + } + ], "suggest": "", "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { "line": 20, - "column": 5, + "column": 7, "endLine": 20, - "endColumn": 12, + "endColumn": 14, "problem": "InteropObjectProperty", "autofix": [ { - "start": 718, - "end": 725, + "start": 721, + "end": 728, "replacementText": "foo.getPropertyByName(\"num\")", "line": 20, - "column": 5, + "column": 7, "endLine": 20, - "endColumn": 12 + "endColumn": 14 } ], "suggest": "", @@ -211,51 +234,83 @@ "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 12, - "problem": "InteropJsObjectUsage", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 10, + "problem": "InteropIncrementDecrement", "autofix": [ { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 718, - "end": 725, - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 12 + "replacementText": "let tmp_1 = foo.getPropertyByName(\"num\").toNumber()\nfoo.setPropertyByName(num, tmp_1 + 1)\ntmp_1 = tmp_1 + 1\n", + "start": 730, + "end": 739, + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 10 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 14, + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 8, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 730, + "end": 737, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 10, "problem": "InteropIncrementDecrement", + "autofix": [ + { + "replacementText": "let tmp_2 = foo.getPropertyByName(\"num\").toNumber()\ntmp_2 = tmp_2 + 1\nfoo.setPropertyByName(num, tmp_2)\n", + "start": 740, + "end": 749, + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 10 + } + ], "suggest": "", "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, { - "line": 21, - "column": 7, - "endLine": 21, - "endColumn": 14, + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 10, "problem": "InteropObjectProperty", "autofix": [ { - "start": 734, - "end": 741, + "start": 742, + "end": 749, "replacementText": "foo.getPropertyByName(\"num\")", - "line": 21, - "column": 7, - "endLine": 21, - "endColumn": 14 + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 10 } ], "suggest": "", @@ -263,25 +318,88 @@ "severity": "ERROR" }, { - "line": 21, - "column": 7, - "endLine": 21, - "endColumn": 14, - "problem": "InteropJsObjectUsage", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 10, + "problem": "InteropIncrementDecrement", "autofix": [ { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 734, - "end": 741, - "line": 21, - "column": 7, - "endLine": 21, - "endColumn": 14 + "replacementText": "let tmp_3 = foo.getPropertyByName(\"num\").toNumber()\nfoo.setPropertyByName(num, tmp_3 - 1)\ntmp_3 = tmp_3 - 1\n", + "start": 750, + "end": 759, + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 8, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 750, + "end": 757, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 10, + "problem": "InteropIncrementDecrement", + "autofix": [ + { + "replacementText": "let tmp_4 = foo.getPropertyByName(\"num\").toNumber()\ntmp_4 = tmp_4 - 1\nfoo.setPropertyByName(num, tmp_4)\n", + "start": 760, + "end": 769, + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 10 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 3, + "endLine": 25, + "endColumn": 10, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 762, + "end": 769, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 25, + "column": 3, + "endLine": 25, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" } ] -} \ No newline at end of file +} diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.json index cf493da1d6fe4df6133341a3e3a1db1489feb321..ca88f857e960b437dcf767c0ac40be998c8f1236 100755 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 52, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets index 3be959d07a495d4fd85795cabcff73c1ea30ae9f..f022ce0834ee6528d5c77bf5bd845590530ea4b7 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.ets @@ -12,12 +12,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' let GeneratedImportVar_1 = ESValue.load('./increases_decreases_js_obj_js'); let foo = GeneratedImportVar_1.getPropertyByName('foo'); let a: number =0.0 -a = foo.getPropertyByName("num")++ -a = ++foo.getPropertyByName("num") -a = foo.getPropertyByName("num")-- -a = --foo.getPropertyByName("num") +a = foo.getPropertyByName("num").toNumber() +foo.setPropertyByName(num, a + 1.0) +a = a + 1.0 + +a = foo.getPropertyByName("num").toNumber() +a = a + 1.0 +foo.setPropertyByName(num, a) + +a = foo.getPropertyByName("num").toNumber() +foo.setPropertyByName(num, a - 1.0) +a = a - 1.0 + +a = foo.getPropertyByName("num").toNumber() +a = a - 1.0 +foo.setPropertyByName(num, a) + + +let tmp_1 = foo.getPropertyByName("num").toNumber() +foo.setPropertyByName(num, tmp_1 + 1.0) +tmp_1 = tmp_1 + 1.0 + +let tmp_2 = foo.getPropertyByName("num").toNumber() +tmp_2 = tmp_2 + 1.0 +foo.setPropertyByName(num, tmp_2) + +let tmp_3 = foo.getPropertyByName("num").toNumber() +foo.setPropertyByName(num, tmp_3 - 1.0) +tmp_3 = tmp_3 - 1.0 + +let tmp_4 = foo.getPropertyByName("num").toNumber() +tmp_4 = tmp_4 - 1.0 +foo.setPropertyByName(num, tmp_4) + diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json index f6439adcf2637a788231915451071c18bc2f4736..0a10b6a69edbbda115aff18cc7d947ae932ec423 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 16, + "line": 15, "column": 5, - "endLine": 16, + "endLine": 15, "endColumn": 75, "problem": "AnyType", "suggest": "", @@ -25,14 +25,54 @@ "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 5, - "endLine": 17, + "endLine": 16, "endColumn": 56, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 5, + "endLine": 40, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 5, + "endLine": 44, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 5, + "endLine": 48, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets b/ets2panda/linter/test/interop/instantiated_js_obj.ets index f24de83f1ac2aea42269962eaa365a8f430dd622..e4208df9fe3ba98ef73b31b1fe28bb5b78d21053 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -'use static' import {Foo, Foo1} from "./instantiated_js_obj_js" class A { num: number = 1; diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.arkts2.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.arkts2.json index d5efb9f32d78bbd43cb4eddaf8e40a4781344054..f116dfb988a075a4decea2af9fadc3167ceb15ba 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.arkts2.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 51, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 19, - "endLine": 19, + "endLine": 18, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 23, + "line": 22, "column": 1, - "endLine": 23, + "endLine": 22, "endColumn": 13, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -55,9 +45,9 @@ "severity": "ERROR" }, { - "line": 23, + "line": 22, "column": 9, - "endLine": 23, + "endLine": 22, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -65,9 +55,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 23, "column": 1, - "endLine": 24, + "endLine": 23, "endColumn": 17, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -75,9 +65,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 24, "column": 1, - "endLine": 25, + "endLine": 24, "endColumn": 17, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -85,9 +75,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 1, - "endLine": 27, + "endLine": 26, "endColumn": 15, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -95,9 +85,9 @@ "severity": "ERROR" }, { - "line": 28, + "line": 27, "column": 1, - "endLine": 28, + "endLine": 27, "endColumn": 11, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -105,9 +95,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 10, - "endLine": 30, + "endLine": 29, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -115,9 +105,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 31, "column": 1, - "endLine": 32, + "endLine": 31, "endColumn": 16, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -125,9 +115,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 32, "column": 1, - "endLine": 33, + "endLine": 32, "endColumn": 23, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -135,9 +125,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 32, "column": 10, - "endLine": 33, + "endLine": 32, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json index 7a22b7b9aa6a59570819d9daf7c69979b32837e8..f9ae170771c98c555d228cd0ac3d36b36294688e 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.autofix.json @@ -15,38 +15,28 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 51, "problem": "InterOpImportJs", "autofix": [ { - "start": 618, - "end": 668, + "start": 605, + "end": 655, "replacementText": "", - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 51 }, { - "start": 668, - "end": 668, + "start": 655, + "end": 655, "replacementText": "let GeneratedImportVar_1 = ESValue.load('./instantiated_js_obj_js');\nlet Foo = GeneratedImportVar_1.getPropertyByName('Foo');\nlet Foo1 = GeneratedImportVar_1.getPropertyByName('Foo1');\n", - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 51 } ], @@ -55,19 +45,19 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 19, - "endLine": 19, + "endLine": 18, "endColumn": 20, "problem": "NumericSemantics", "autofix": [ { - "start": 697, - "end": 698, + "start": 684, + "end": 685, "replacementText": "1.0", - "line": 19, + "line": 18, "column": 19, - "endLine": 19, + "endLine": 18, "endColumn": 20 } ], @@ -76,19 +66,19 @@ "severity": "ERROR" }, { - "line": 23, + "line": 22, "column": 1, - "endLine": 23, + "endLine": 22, "endColumn": 13, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 728, - "end": 740, + "start": 715, + "end": 727, "replacementText": "Foo.instantiate(ESValue.wrap(123))", - "line": 23, + "line": 22, "column": 1, - "endLine": 23, + "endLine": 22, "endColumn": 13 } ], @@ -97,19 +87,19 @@ "severity": "ERROR" }, { - "line": 23, + "line": 22, "column": 9, - "endLine": 23, + "endLine": 22, "endColumn": 12, "problem": "NumericSemantics", "autofix": [ { - "start": 736, - "end": 739, + "start": 723, + "end": 726, "replacementText": "123.0", - "line": 23, + "line": 22, "column": 9, - "endLine": 23, + "endLine": 22, "endColumn": 12 } ], @@ -118,19 +108,19 @@ "severity": "ERROR" }, { - "line": 24, + "line": 23, "column": 1, - "endLine": 24, + "endLine": 23, "endColumn": 17, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 741, - "end": 757, + "start": 728, + "end": 744, "replacementText": "Foo.instantiate(ESValue.wrap('hello'))", - "line": 24, + "line": 23, "column": 1, - "endLine": 24, + "endLine": 23, "endColumn": 17 } ], @@ -139,19 +129,19 @@ "severity": "ERROR" }, { - "line": 25, + "line": 24, "column": 1, - "endLine": 25, + "endLine": 24, "endColumn": 17, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 758, - "end": 774, + "start": 745, + "end": 761, "replacementText": "Foo.instantiate(ESValue.wrap(new A()))", - "line": 25, + "line": 24, "column": 1, - "endLine": 25, + "endLine": 24, "endColumn": 17 } ], @@ -160,19 +150,19 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 1, - "endLine": 27, + "endLine": 26, "endColumn": 15, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 795, - "end": 809, + "start": 782, + "end": 796, "replacementText": "Foo.instantiate(ESValue.wrap(a.num))", - "line": 27, + "line": 26, "column": 1, - "endLine": 27, + "endLine": 26, "endColumn": 15 } ], @@ -181,19 +171,19 @@ "severity": "ERROR" }, { - "line": 28, + "line": 27, "column": 1, - "endLine": 28, + "endLine": 27, "endColumn": 11, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 810, - "end": 820, + "start": 797, + "end": 807, "replacementText": "Foo.instantiate(ESValue.wrap(a))", - "line": 28, + "line": 27, "column": 1, - "endLine": 28, + "endLine": 27, "endColumn": 11 } ], @@ -202,19 +192,19 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 10, - "endLine": 30, + "endLine": 29, "endColumn": 11, "problem": "NumericSemantics", "autofix": [ { - "start": 856, - "end": 857, + "start": 843, + "end": 844, "replacementText": "1.0", - "line": 30, + "line": 29, "column": 10, - "endLine": 30, + "endLine": 29, "endColumn": 11 } ], @@ -223,19 +213,19 @@ "severity": "ERROR" }, { - "line": 32, + "line": 31, "column": 1, - "endLine": 32, + "endLine": 31, "endColumn": 16, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 861, - "end": 876, + "start": 848, + "end": 863, "replacementText": "Foo.instantiate(ESValue.wrap(test()))", - "line": 32, + "line": 31, "column": 1, - "endLine": 32, + "endLine": 31, "endColumn": 16 } ], @@ -244,16 +234,20 @@ "severity": "ERROR" }, { - "line": 33, + "line": 32, "column": 1, - "endLine": 33, + "endLine": 32, "endColumn": 23, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 877, - "end": 899, - "replacementText": "Foo1.instantiate(ESValue.wrap(123), ESValue.wrap('hello'))" + "start": 864, + "end": 886, + "replacementText": "Foo1.instantiate(ESValue.wrap(123), ESValue.wrap('hello'))", + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 23 } ], "suggest": "", @@ -261,19 +255,19 @@ "severity": "ERROR" }, { - "line": 33, + "line": 32, "column": 10, - "endLine": 33, + "endLine": 32, "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 886, - "end": 889, + "start": 873, + "end": 876, "replacementText": "123.0", - "line": 33, + "line": 32, "column": 10, - "endLine": 33, + "endLine": 32, "endColumn": 13 } ], diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.json index ad8f5eb1ae4e1f2ec507367301510cbc9e65607a..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets index 06c8b9ee788e412fb2c6fb8714383fc97dd0c4c7..b033816ddb15de3ae08e462513ec1258f69269e8 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -'use static' let GeneratedImportVar_1 = ESValue.load('./instantiated_js_obj_js'); let Foo = GeneratedImportVar_1.getPropertyByName('Foo'); let Foo1 = GeneratedImportVar_1.getPropertyByName('Foo1'); diff --git a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json index 915dad64c5a1d8dc688978d40079ee4b0251ddbb..2084de8763deeb4f9899489c2da2f6cf454ad82d 100644 --- a/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json +++ b/ets2panda/linter/test/interop/instantiated_js_obj.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 5, - "endLine": 17, + "endLine": 16, "endColumn": 68, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 56, "problem": "AnyType", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 5, - "endLine": 19, + "endLine": 18, "endColumn": 58, "problem": "AnyType", "suggest": "", @@ -45,4 +45,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets b/ets2panda/linter/test/interop/interop_convert_import.ets old mode 100755 new mode 100644 index e5fa5c03c701717dc5e791b70d1043afd8c49411..02426a43180b9f34518bb0f1601ca6425a1084b6 --- a/ets2panda/linter/test/interop/interop_convert_import.ets +++ b/ets2panda/linter/test/interop/interop_convert_import.ets @@ -1,3 +1,4 @@ +<<<<<<< HEAD /* * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -38,4 +39,27 @@ return null_val as null === null;// 扫描出 arkts-interop-js2s-convert-js-type // convert type - undefined test_helper.test(() => { return undefined_val as undefined === undefined; // 扫描出 arkts-interop-js2s-convert-js-type - no pass -}, "undefined_val as undefined === undefined"); \ No newline at end of file +}, "undefined_val as undefined === undefined"); +======= +/* + * 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 {foo, foo2, foo3, foo4} from "./interop_convert_import_js.js" + + let a: number = foo.num as number + let a: boolean = foo2.bool as boolean + let a: string = foo3.str as string + let a: bigint = foo4.big as bigint" +>>>>>>> efeb0a81e (modify use static spec) diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json b/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json old mode 100755 new mode 100644 index b6255d07e7a6601ae97f487ce3c873f2526dea10..d6f91a557d1e1a3e03b5b1a4c6049645c84a0a5b --- a/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json @@ -1,268 +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": 17, - "column": 2, - "endLine": 17, - "endColumn": 106, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 106, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 18, - "endLine": 19, - "endColumn": 35, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 18, - "endLine": 19, - "endColumn": 25, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 18, - "endLine": 19, - "endColumn": 25, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 20, - "endLine": 20, - "endColumn": 41, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 20, - "endLine": 20, - "endColumn": 29, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 20, - "endLine": 20, - "endColumn": 29, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 19, - "endLine": 21, - "endColumn": 38, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 19, - "endLine": 21, - "endColumn": 27, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 19, - "endLine": 21, - "endColumn": 27, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 19, - "endLine": 22, - "endColumn": 38, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 19, - "endLine": 22, - "endColumn": 27, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 19, - "endLine": 22, - "endColumn": 27, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 9, - "endLine": 25, - "endColumn": 27, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 44, - "endLine": 25, - "endColumn": 62, - "problem": "GenericCallNoTypeArgs", - "suggest": "", - "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 54, - "endLine": 25, - "endColumn": 55, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 57, - "endLine": 25, - "endColumn": 58, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 60, - "endLine": 25, - "endColumn": 61, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 9, - "endLine": 30, - "endColumn": 30, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 48, - "endLine": 30, - "endColumn": 49, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 50, - "endLine": 30, - "endColumn": 51, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 52, - "endLine": 30, - "endColumn": 53, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 35, - "column": 8, - "endLine": 35, - "endColumn": 24, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "severity": "ERROR" - }, - { - "line": 40, - "column": 8, - "endLine": 40, - "endColumn": 34, - "problem": "InterOpConvertImport", - "suggest": "", - "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", - "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": 18, + "column": 2, + "endLine": 18, + "endColumn": 106, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 106, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 18, + "endLine": 20, + "endColumn": 35, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 18, + "endLine": 20, + "endColumn": 25, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 20, + "endLine": 21, + "endColumn": 41, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 20, + "endLine": 21, + "endColumn": 29, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 19, + "endLine": 22, + "endColumn": 38, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 19, + "endLine": 22, + "endColumn": 27, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 19, + "endLine": 23, + "endColumn": 38, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 19, + "endLine": 23, + "endColumn": 27, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 27, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 44, + "endLine": 26, + "endColumn": 62, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 54, + "endLine": 26, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 57, + "endLine": 26, + "endColumn": 58, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 60, + "endLine": 26, + "endColumn": 61, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 9, + "endLine": 31, + "endColumn": 30, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 48, + "endLine": 31, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 50, + "endLine": 31, + "endColumn": 51, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 52, + "endLine": 31, + "endColumn": 53, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 8, + "endLine": 36, + "endColumn": 24, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 8, + "endLine": 41, + "endColumn": 34, + "problem": "InterOpConvertImport", + "suggest": "", + "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json index 5aca1b631b25ea9f330ddc65ce1643eda034b81d..b49b275bb55fe496eed776379f50e210e3354a4b 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json @@ -13,11 +13,11 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], -"result": [ + "result": [ { - "line": 17, + "line": 18, "column": 2, - "endLine": 17, + "endLine": 18, "endColumn": 106, "problem": "ImportAfterStatement", "suggest": "", @@ -25,28 +25,28 @@ "severity": "ERROR" }, { - "line": 17, + "line": 18, "column": 2, - "endLine": 17, + "endLine": 18, "endColumn": 106, "problem": "InterOpImportJs", "autofix": [ { - "start": 636, - "end": 740, + "start": 649, + "end": 753, "replacementText": "", - "line": 17, + "line": 18, "column": 2, - "endLine": 17, + "endLine": 18, "endColumn": 106 }, { - "start": 740, - "end": 740, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_convert_import_js.js');\r\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\r\nlet foo2 = GeneratedImportVar_1.getPropertyByName('foo2');\r\nlet foo3 = GeneratedImportVar_1.getPropertyByName('foo3');\r\nlet foo4 = GeneratedImportVar_1.getPropertyByName('foo4');\r\nlet array_val = GeneratedImportVar_1.getPropertyByName('array_val');\r\nlet null_val = GeneratedImportVar_1.getPropertyByName('null_val');\r\nlet undefined_val = GeneratedImportVar_1.getPropertyByName('undefined_val');\r\n", - "line": 17, + "start": 753, + "end": 753, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_convert_import_js.js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\nlet foo2 = GeneratedImportVar_1.getPropertyByName('foo2');\nlet foo3 = GeneratedImportVar_1.getPropertyByName('foo3');\nlet foo4 = GeneratedImportVar_1.getPropertyByName('foo4');\nlet array_val = GeneratedImportVar_1.getPropertyByName('array_val');\nlet null_val = GeneratedImportVar_1.getPropertyByName('null_val');\nlet undefined_val = GeneratedImportVar_1.getPropertyByName('undefined_val');\n", + "line": 18, "column": 2, - "endLine": 17, + "endLine": 18, "endColumn": 106 } ], @@ -55,19 +55,19 @@ "severity": "ERROR" }, { - "line": 19, + "line": 20, "column": 18, - "endLine": 19, + "endLine": 20, "endColumn": 35, "problem": "InterOpConvertImport", "autofix": [ { - "start": 761, - "end": 778, + "start": 774, + "end": 791, "replacementText": "foo.getPropertyByName(\"num\").toNumber()", - "line": 19, + "line": 20, "column": 18, - "endLine": 19, + "endLine": 20, "endColumn": 35 } ], @@ -76,19 +76,19 @@ "severity": "ERROR" }, { - "line": 19, + "line": 20, "column": 18, - "endLine": 19, + "endLine": 20, "endColumn": 25, "problem": "InteropObjectProperty", "autofix": [ { - "start": 761, - "end": 768, + "start": 774, + "end": 781, "replacementText": "foo.getPropertyByName(\"num\")", - "line": 19, + "line": 20, "column": 18, - "endLine": 19, + "endLine": 20, "endColumn": 25 } ], @@ -97,40 +97,19 @@ "severity": "ERROR" }, { - "line": 19, - "column": 18, - "endLine": 19, - "endColumn": 25, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('num')", - "start": 761, - "end": 768, - "line": 19, - "column": 18, - "endLine": 19, - "endColumn": 25 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 20, + "line": 21, "column": 20, - "endLine": 20, + "endLine": 21, "endColumn": 41, "problem": "InterOpConvertImport", "autofix": [ { - "start": 799, - "end": 820, + "start": 812, + "end": 833, "replacementText": "foo2.getPropertyByName(\"bool\").toBoolean()", - "line": 20, + "line": 21, "column": 20, - "endLine": 20, + "endLine": 21, "endColumn": 41 } ], @@ -139,19 +118,19 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 20, - "endLine": 20, + "endLine": 21, "endColumn": 29, "problem": "InteropObjectProperty", "autofix": [ { - "start": 799, - "end": 808, + "start": 812, + "end": 821, "replacementText": "foo2.getPropertyByName(\"bool\")", - "line": 20, + "line": 21, "column": 20, - "endLine": 20, + "endLine": 21, "endColumn": 29 } ], @@ -160,40 +139,19 @@ "severity": "ERROR" }, { - "line": 20, - "column": 20, - "endLine": 20, - "endColumn": 29, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo2.getPropertyByName('bool').toBoolean()", - "start": 799, - "end": 808, - "line": 20, - "column": 20, - "endLine": 20, - "endColumn": 29 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 21, + "line": 22, "column": 19, - "endLine": 21, + "endLine": 22, "endColumn": 38, "problem": "InterOpConvertImport", "autofix": [ { - "start": 840, - "end": 859, + "start": 853, + "end": 872, "replacementText": "foo3.getPropertyByName(\"str\").toString()", - "line": 21, + "line": 22, "column": 19, - "endLine": 21, + "endLine": 22, "endColumn": 38 } ], @@ -202,19 +160,19 @@ "severity": "ERROR" }, { - "line": 21, + "line": 22, "column": 19, - "endLine": 21, + "endLine": 22, "endColumn": 27, "problem": "InteropObjectProperty", "autofix": [ { - "start": 840, - "end": 848, + "start": 853, + "end": 861, "replacementText": "foo3.getPropertyByName(\"str\")", - "line": 21, + "line": 22, "column": 19, - "endLine": 21, + "endLine": 22, "endColumn": 27 } ], @@ -223,40 +181,19 @@ "severity": "ERROR" }, { - "line": 21, - "column": 19, - "endLine": 21, - "endColumn": 27, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo3.getPropertyByName('str').toString()", - "start": 840, - "end": 848, - "line": 21, - "column": 19, - "endLine": 21, - "endColumn": 27 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 22, + "line": 23, "column": 19, - "endLine": 22, + "endLine": 23, "endColumn": 38, "problem": "InterOpConvertImport", "autofix": [ { - "start": 879, - "end": 898, + "start": 892, + "end": 911, "replacementText": "foo4.getPropertyByName(\"big\").toBigInt()", - "line": 22, + "line": 23, "column": 19, - "endLine": 22, + "endLine": 23, "endColumn": 38 } ], @@ -265,19 +202,19 @@ "severity": "ERROR" }, { - "line": 22, + "line": 23, "column": 19, - "endLine": 22, + "endLine": 23, "endColumn": 27, "problem": "InteropObjectProperty", "autofix": [ { - "start": 879, - "end": 887, + "start": 892, + "end": 900, "replacementText": "foo4.getPropertyByName(\"big\")", - "line": 22, + "line": 23, "column": 19, - "endLine": 22, + "endLine": 23, "endColumn": 27 } ], @@ -286,30 +223,9 @@ "severity": "ERROR" }, { - "line": 22, - "column": 19, - "endLine": 22, - "endColumn": 27, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo4.getPropertyByName('big')", - "start": 879, - "end": 887, - "line": 22, - "column": 19, - "endLine": 22, - "endColumn": 27 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 25, + "line": 26, "column": 9, - "endLine": 25, + "endLine": 26, "endColumn": 27, "problem": "InterOpConvertImport", "suggest": "", @@ -317,9 +233,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 44, - "endLine": 25, + "endLine": 26, "endColumn": 62, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -327,19 +243,19 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 54, - "endLine": 25, + "endLine": 26, "endColumn": 55, "problem": "NumericSemantics", "autofix": [ { - "start": 981, - "end": 982, + "start": 994, + "end": 995, "replacementText": "1.0", - "line": 25, + "line": 26, "column": 54, - "endLine": 25, + "endLine": 26, "endColumn": 55 } ], @@ -348,19 +264,19 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 57, - "endLine": 25, + "endLine": 26, "endColumn": 58, "problem": "NumericSemantics", "autofix": [ { - "start": 984, - "end": 985, + "start": 997, + "end": 998, "replacementText": "2.0", - "line": 25, + "line": 26, "column": 57, - "endLine": 25, + "endLine": 26, "endColumn": 58 } ], @@ -369,19 +285,19 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 60, - "endLine": 25, + "endLine": 26, "endColumn": 61, "problem": "NumericSemantics", "autofix": [ { - "start": 987, - "end": 988, + "start": 1000, + "end": 1001, "replacementText": "3.0", - "line": 25, + "line": 26, "column": 60, - "endLine": 25, + "endLine": 26, "endColumn": 61 } ], @@ -390,9 +306,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 31, "column": 9, - "endLine": 30, + "endLine": 31, "endColumn": 30, "problem": "InterOpConvertImport", "suggest": "", @@ -400,19 +316,19 @@ "severity": "ERROR" }, { - "line": 30, + "line": 31, "column": 48, - "endLine": 30, + "endLine": 31, "endColumn": 49, "problem": "NumericSemantics", "autofix": [ { - "start": 1195, - "end": 1196, + "start": 1208, + "end": 1209, "replacementText": "1.0", - "line": 30, + "line": 31, "column": 48, - "endLine": 30, + "endLine": 31, "endColumn": 49 } ], @@ -421,19 +337,19 @@ "severity": "ERROR" }, { - "line": 30, + "line": 31, "column": 50, - "endLine": 30, + "endLine": 31, "endColumn": 51, "problem": "NumericSemantics", "autofix": [ { - "start": 1197, - "end": 1198, + "start": 1210, + "end": 1211, "replacementText": "2.0", - "line": 30, + "line": 31, "column": 50, - "endLine": 30, + "endLine": 31, "endColumn": 51 } ], @@ -442,19 +358,19 @@ "severity": "ERROR" }, { - "line": 30, + "line": 31, "column": 52, - "endLine": 30, + "endLine": 31, "endColumn": 53, "problem": "NumericSemantics", "autofix": [ { - "start": 1199, - "end": 1200, + "start": 1212, + "end": 1213, "replacementText": "3.0", - "line": 30, + "line": 31, "column": 52, - "endLine": 30, + "endLine": 31, "endColumn": 53 } ], @@ -463,9 +379,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 8, - "endLine": 35, + "endLine": 36, "endColumn": 24, "problem": "InterOpConvertImport", "suggest": "", @@ -473,9 +389,9 @@ "severity": "ERROR" }, { - "line": 40, + "line": 41, "column": 8, - "endLine": 40, + "endLine": 41, "endColumn": 34, "problem": "InterOpConvertImport", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.json b/ets2panda/linter/test/interop/interop_convert_import.ets.json index ac2dfbe6f88152a66598a802845b33446231f158..5a3f5938e4936b27eb26b147f0b5c49254d3902a 100755 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.json @@ -1,28 +1,28 @@ -{ - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 106, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "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": 18, + "column": 2, + "endLine": 18, + "endColumn": 106, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets index a1c78f19fe4dd5abd335e8077954a615728ff605..1e107cf338e0678a330243f31895744ea396b428 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.ets @@ -1,3 +1,54 @@ +<<<<<<< HEAD +/* + * 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. + */ + 'use static' + + let GeneratedImportVar_1 = ESValue.load('./interop_convert_import_js.js'); +let foo = GeneratedImportVar_1.getPropertyByName('foo'); +let foo2 = GeneratedImportVar_1.getPropertyByName('foo2'); +let foo3 = GeneratedImportVar_1.getPropertyByName('foo3'); +let foo4 = GeneratedImportVar_1.getPropertyByName('foo4'); +let array_val = GeneratedImportVar_1.getPropertyByName('array_val'); +let null_val = GeneratedImportVar_1.getPropertyByName('null_val'); +let undefined_val = GeneratedImportVar_1.getPropertyByName('undefined_val'); + + + let a: number = foo.getPropertyByName("num").toNumber() + let a1: boolean = foo2.getPropertyByName("bool").toBoolean() + let a2: string = foo3.getPropertyByName("str").toString() + let a3: bigint = foo4.getPropertyByName("big").toBigInt() + +test_helper.test(() => { +return (array_val as Array).toString() === new Array(1.0, 2.0, 3.0).toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass +}, "array_val as Array === [1, 2, 3]"); + +// convert type - Array +test_helper.test(() => { +return (array_val as number[]).toString() === [1.0,2.0,3.0].toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass +}, "array_val as Array === [1, 2, 3]"); + +// convert type - null +test_helper.test(() => { +return null_val as null === null;// 扫描出 arkts-interop-js2s-convert-js-type - no pass +}, "null_val as null === null"); + +// convert type - undefined +test_helper.test(() => { +return undefined_val as undefined === undefined; // 扫描出 arkts-interop-js2s-convert-js-type - no pass +}, "undefined_val as undefined === undefined"); +======= /* * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,38 +63,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - 'use static' - - let GeneratedImportVar_1 = ESValue.load('./interop_convert_import_js.js'); -let foo = GeneratedImportVar_1.getPropertyByName('foo'); -let foo2 = GeneratedImportVar_1.getPropertyByName('foo2'); -let foo3 = GeneratedImportVar_1.getPropertyByName('foo3'); -let foo4 = GeneratedImportVar_1.getPropertyByName('foo4'); -let array_val = GeneratedImportVar_1.getPropertyByName('array_val'); -let null_val = GeneratedImportVar_1.getPropertyByName('null_val'); -let undefined_val = GeneratedImportVar_1.getPropertyByName('undefined_val'); - - - let a: number = foo.getPropertyByName("num").toNumber() - let a1: boolean = foo2.getPropertyByName("bool").toBoolean() - let a2: string = foo3.getPropertyByName("str").toString() - let a3: bigint = foo4.getPropertyByName("big").toBigInt() - -test_helper.test(() => { -return (array_val as Array).toString() === new Array(1.0, 2.0, 3.0).toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass -}, "array_val as Array === [1, 2, 3]"); - -// convert type - Array -test_helper.test(() => { -return (array_val as number[]).toString() === [1.0,2.0,3.0].toString();// 扫描出 arkts-interop-js2s-convert-js-type - no pass -}, "array_val as Array === [1, 2, 3]"); -// convert type - null -test_helper.test(() => { -return null_val as null === null;// 扫描出 arkts-interop-js2s-convert-js-type - no pass -}, "null_val as null === null"); + import {foo, foo2, foo3, foo4} from "./interop_convert_import_js.js" -// convert type - undefined -test_helper.test(() => { -return undefined_val as undefined === undefined; // 扫描出 arkts-interop-js2s-convert-js-type - no pass -}, "undefined_val as undefined === undefined"); \ No newline at end of file + let a: number = foo.num as number + let a: boolean = foo2.bool as boolean + let a: string = foo3.str as string + let a: bigint = foo4.big as bigint" +>>>>>>> efeb0a81e (modify use static spec) diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json index 85e135eccaf3a8ff3af35cc57543a8218bd575ba..a49b70a95279536d6b68fb9d7385dd46c5986998 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.migrate.json @@ -14,21 +14,11 @@ "limitations under the License." ], "result": [ - { - "line": 17, - "column": 6, - "endLine": 17, - "endColumn": 75, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, { "line": 18, - "column": 5, + "column": 6, "endLine": 18, - "endColumn": 56, + "endColumn": 75, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -38,7 +28,7 @@ "line": 19, "column": 5, "endLine": 19, - "endColumn": 58, + "endColumn": 56, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -68,7 +58,7 @@ "line": 22, "column": 5, "endLine": 22, - "endColumn": 68, + "endColumn": 58, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -78,7 +68,7 @@ "line": 23, "column": 5, "endLine": 23, - "endColumn": 66, + "endColumn": 68, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -88,6 +78,16 @@ "line": 24, "column": 5, "endLine": 24, + "endColumn": 66, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, "endColumn": 76, "problem": "AnyType", "suggest": "", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 44, - "endLine": 33, + "endLine": 34, "endColumn": 68, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -105,9 +105,9 @@ "severity": "ERROR" }, { - "line": 43, + "line": 44, "column": 8, - "endLine": 43, + "endLine": 44, "endColumn": 24, "problem": "InterOpConvertImport", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets b/ets2panda/linter/test/interop/interop_equality_judgment.ets index 7fe09978d32180c20921249f108ba7cdcd3eea11..65ce20fddcdcb02a9f4cfa54fc92aafdea6934c7 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -'use static' import {a, b} from "./interop_equality_judgment_js" a == b a != b diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json index 916e1b51ca421151b76bc22d2ee1aa9b32f60213..920de865a7bf8abad43c5dda169887cb74d79938 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.arkts2.json @@ -15,23 +15,23 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 52, - "problem": "ImportAfterStatement", + "problem": "InterOpImportJs", "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { "line": 17, "column": 1, "endLine": 17, - "endColumn": 52, - "problem": "InterOpImportJs", + "endColumn": 7, + "problem": "InteropEqualityJudgment", "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", "severity": "ERROR" }, { @@ -48,7 +48,7 @@ "line": 19, "column": 1, "endLine": 19, - "endColumn": 7, + "endColumn": 8, "problem": "InteropEqualityJudgment", "suggest": "", "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", @@ -63,16 +63,6 @@ "suggest": "", "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 8, - "problem": "InteropEqualityJudgment", - "suggest": "", - "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", - "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json index c198972221d4d346f4dde0fe036a3063555b2754..7145a50507beed4836a0eebfd568eacf2a450d36 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.autofix.json @@ -15,31 +15,29 @@ ], "result": [ { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 52, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 52, "problem": "InterOpImportJs", "autofix": [ { - "start": 618, - "end": 669, - "replacementText": "" + "start": 605, + "end": 656, + "replacementText": "", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 52 }, { - "start": 669, - "end": 669, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_equality_judgment_js');\nlet a = GeneratedImportVar_1.getPropertyByName('a');\nlet b = GeneratedImportVar_1.getPropertyByName('b');\n" + "start": 656, + "end": 656, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_equality_judgment_js');\nlet a = GeneratedImportVar_1.getPropertyByName('a');\nlet b = GeneratedImportVar_1.getPropertyByName('b');\n", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 52 } ], "suggest": "", @@ -47,16 +45,20 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 1, - "endLine": 18, + "endLine": 17, "endColumn": 7, "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 670, - "end": 676, - "replacementText": "a.areEqual(b)" + "start": 657, + "end": 663, + "replacementText": "a.areEqual(b)", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 7 } ], "suggest": "", @@ -64,16 +66,20 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 7, "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 677, - "end": 683, - "replacementText": "!a.areEqual(b)" + "start": 664, + "end": 670, + "replacementText": "!a.areEqual(b)", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 7 } ], "suggest": "", @@ -81,16 +87,20 @@ "severity": "ERROR" }, { - "line": 20, + "line": 19, "column": 1, - "endLine": 20, + "endLine": 19, "endColumn": 8, "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 684, - "end": 691, - "replacementText": "a.areStrictlyEqual(b)" + "start": 671, + "end": 678, + "replacementText": "a.areStrictlyEqual(b)", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 8 } ], "suggest": "", @@ -98,16 +108,20 @@ "severity": "ERROR" }, { - "line": 21, + "line": 20, "column": 1, - "endLine": 21, + "endLine": 20, "endColumn": 8, "problem": "InteropEqualityJudgment", "autofix": [ { - "start": 692, - "end": 699, - "replacementText": "!a.areStrictlyEqual(b)" + "start": 679, + "end": 686, + "replacementText": "!a.areStrictlyEqual(b)", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 8 } ], "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.json index e48cf9a99b2e3b05e8a7816bda0738a37d257d25..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 52, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets index 8bbbd750c94aad92eee85fa254a6b36667be9a91..796cf7f898e1eab3f91e4b33bfa2bc582fe3a560 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -'use static' let GeneratedImportVar_1 = ESValue.load('./interop_equality_judgment_js'); let a = GeneratedImportVar_1.getPropertyByName('a'); let b = GeneratedImportVar_1.getPropertyByName('b'); diff --git a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json index a3c218b7b22380ea1dc4fdd6c6b1353462bb2ec7..c3d33e531ccd89abf012408dcd79eff047a1c31a 100644 --- a/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_equality_judgment.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 5, - "endLine": 17, + "endLine": 16, "endColumn": 74, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 52, "problem": "AnyType", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 5, - "endLine": 19, + "endLine": 18, "endColumn": 52, "problem": "AnyType", "suggest": "", @@ -45,4 +45,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_export_js_rules.ets b/ets2panda/linter/test/interop/interop_export_js_rules.ets index 4e6b76262c18f4311735b63c041db527415e7491..e729a7c2c33e0c93df578af5602395f62ff99b07 100644 --- a/ets2panda/linter/test/interop/interop_export_js_rules.ets +++ b/ets2panda/linter/test/interop/interop_export_js_rules.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' import { ff1 } from "./interop_import_js_rules_js" diff --git a/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json b/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json index 4fc44d8a3c257a8f336c85a17edce0306d0745b6..1f92c538cd5688b2fadd03034e6f073f0b789851 100644 --- a/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json @@ -1,88 +1,88 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 13, - "problem": "InteropJsObjectExport", - "suggest": "", - "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 51, - "problem": "InteropJsObjectExport", - "suggest": "", - "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 57, - "problem": "InteropArkTs1ObjectExport", - "suggest": "", - "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 57, - "problem": "InteropArkTs1ObjectExport", - "suggest": "", - "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 59, - "problem": "InteropJsObjectExport", - "suggest": "", - "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", - "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": 16, + "column": 1, + "endLine": 16, + "endColumn": 51, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 13, + "problem": "InteropJsObjectExport", + "suggest": "", + "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 51, + "problem": "InteropJsObjectExport", + "suggest": "", + "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 57, + "problem": "InteropArkTs1ObjectExport", + "suggest": "", + "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 57, + "problem": "InteropArkTs1ObjectExport", + "suggest": "", + "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 57, + "problem": "InteropArkTs1ObjectExport", + "suggest": "", + "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 1, + "endLine": 28, + "endColumn": 59, + "problem": "InteropJsObjectExport", + "suggest": "", + "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_export_js_rules.ets.json b/ets2panda/linter/test/interop/interop_export_js_rules.ets.json index 91f5b61ed193b5db1f2d82123a53ba9fe017a31c..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/interop_export_js_rules.ets.json +++ b/ets2panda/linter/test/interop/interop_export_js_rules.ets.json @@ -1,28 +1,17 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "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": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js.ets b/ets2panda/linter/test/interop/interop_import_js.ets old mode 100755 new mode 100644 index 3325f1bdd99c47feb42c89a27bb2d2255338121a..337d1600c68dd251a1f27b9d96ffb214dcfdf69f --- a/ets2panda/linter/test/interop/interop_import_js.ets +++ b/ets2panda/linter/test/interop/interop_import_js.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -'use static' import { Cjs } from '../main/js_lib'; import { fjs } from '../main/js_lib'; import { CPreview,bar,foo } from "./jsfiles/preview_import_js"; diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.arkts2.json b/ets2panda/linter/test/interop/interop_import_js.ets.arkts2.json index 17f26fd8dcbe4b296c8ad46a6dbf16de2323964d..7d56ee5afdf8f7d33dc5624dcf3c823daece3e83 100755 --- a/ets2panda/linter/test/interop/interop_import_js.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.arkts2.json @@ -15,13 +15,13 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 38, - "problem": "ImportAfterStatement", + "problem": "InterOpImportJs", "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { @@ -38,17 +38,7 @@ "line": 18, "column": 1, "endLine": 18, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 38, + "endColumn": 64, "problem": "InterOpImportJs", "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", @@ -58,17 +48,7 @@ "line": 19, "column": 1, "endLine": 19, - "endColumn": 64, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 64, + "endColumn": 44, "problem": "InterOpImportJs", "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", @@ -78,17 +58,7 @@ "line": 20, "column": 1, "endLine": 20, - "endColumn": 44, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 44, + "endColumn": 57, "problem": "InterOpImportJs", "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", @@ -98,17 +68,7 @@ "line": 21, "column": 1, "endLine": 21, - "endColumn": 57, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 57, + "endColumn": 53, "problem": "InterOpImportJs", "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", @@ -118,36 +78,6 @@ "line": 22, "column": 1, "endLine": 22, - "endColumn": 53, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 53, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 59, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 1, - "endLine": 23, "endColumn": 59, "problem": "InterOpImportJs", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json index 295af0943a99c5d99568ab2f2bae99ac55c17fa7..bda0908dba95e9ecf61d0584931495ee7fa10762 100755 --- a/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.autofix.json @@ -15,31 +15,29 @@ ], "result": [ { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 38, "problem": "InterOpImportJs", "autofix": [ { - "start": 619, - "end": 656, - "replacementText": "" + "start": 606, + "end": 643, + "replacementText": "", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 38 }, { - "start": 971, - "end": 971, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('../main/js_lib');\nlet Cjs = GeneratedImportVar_1.getPropertyByName('Cjs');\n" + "start": 958, + "end": 958, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('../main/js_lib');\nlet Cjs = GeneratedImportVar_1.getPropertyByName('Cjs');\n", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 38 } ], "suggest": "", @@ -47,31 +45,29 @@ "severity": "ERROR" }, { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, + "line": 17, "column": 1, - "endLine": 18, + "endLine": 17, "endColumn": 38, "problem": "InterOpImportJs", "autofix": [ { - "start": 657, - "end": 694, - "replacementText": "" + "start": 644, + "end": 681, + "replacementText": "", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 38 }, { - "start": 971, - "end": 971, - "replacementText": "let GeneratedImportVar_2 = ESValue.load('../main/js_lib');\nlet fjs = GeneratedImportVar_2.getPropertyByName('fjs');\n" + "start": 958, + "end": 958, + "replacementText": "let GeneratedImportVar_2 = ESValue.load('../main/js_lib');\nlet fjs = GeneratedImportVar_2.getPropertyByName('fjs');\n", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 38 } ], "suggest": "", @@ -79,31 +75,29 @@ "severity": "ERROR" }, { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 64, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 64, "problem": "InterOpImportJs", "autofix": [ { - "start": 695, - "end": 758, - "replacementText": "" + "start": 682, + "end": 745, + "replacementText": "", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 64 }, { - "start": 971, - "end": 971, - "replacementText": "let GeneratedImportVar_3 = ESValue.load('./jsfiles/preview_import_js');\nlet CPreview = GeneratedImportVar_3.getPropertyByName('CPreview');\nlet bar = GeneratedImportVar_3.getPropertyByName('bar');\nlet foo = GeneratedImportVar_3.getPropertyByName('foo');\n" + "start": 958, + "end": 958, + "replacementText": "let GeneratedImportVar_3 = ESValue.load('./jsfiles/preview_import_js');\nlet CPreview = GeneratedImportVar_3.getPropertyByName('CPreview');\nlet bar = GeneratedImportVar_3.getPropertyByName('bar');\nlet foo = GeneratedImportVar_3.getPropertyByName('foo');\n", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 64 } ], "suggest": "", @@ -111,31 +105,29 @@ "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 44, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 20, + "line": 19, "column": 1, - "endLine": 20, + "endLine": 19, "endColumn": 44, "problem": "InterOpImportJs", "autofix": [ { - "start": 759, - "end": 802, - "replacementText": "" + "start": 746, + "end": 789, + "replacementText": "", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 44 }, { - "start": 971, - "end": 971, - "replacementText": "let GeneratedImportVar_4 = ESValue.load('./interop_import_js_js');\nlet myAaa = GeneratedImportVar_4.getPropertyByName('aaa');\n" + "start": 958, + "end": 958, + "replacementText": "let GeneratedImportVar_4 = ESValue.load('./interop_import_js_js');\nlet myAaa = GeneratedImportVar_4.getPropertyByName('aaa');\n", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 44 } ], "suggest": "", @@ -143,31 +135,29 @@ "severity": "ERROR" }, { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 57, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 21, + "line": 20, "column": 1, - "endLine": 21, + "endLine": 20, "endColumn": 57, "problem": "InterOpImportJs", "autofix": [ { - "start": 803, - "end": 859, - "replacementText": "" + "start": 790, + "end": 846, + "replacementText": "", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 57 }, { - "start": 971, - "end": 971, - "replacementText": "let GeneratedImportVar_5 = ESValue.load('./interop_import_js_js');\nlet myAaa = GeneratedImportVar_5.getPropertyByName('aaa');\nlet ClassA = GeneratedImportVar_5.getPropertyByName('ClassA');\nlet Dog = GeneratedImportVar_5.getPropertyByName('Dog');\n" + "start": 958, + "end": 958, + "replacementText": "let GeneratedImportVar_5 = ESValue.load('./interop_import_js_js');\nlet myAaa = GeneratedImportVar_5.getPropertyByName('aaa');\nlet ClassA = GeneratedImportVar_5.getPropertyByName('ClassA');\nlet Dog = GeneratedImportVar_5.getPropertyByName('Dog');\n", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 57 } ], "suggest": "", @@ -175,31 +165,29 @@ "severity": "ERROR" }, { - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 53, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 22, + "line": 21, "column": 1, - "endLine": 22, + "endLine": 21, "endColumn": 53, "problem": "InterOpImportJs", "autofix": [ { - "start": 860, - "end": 912, - "replacementText": "" + "start": 847, + "end": 899, + "replacementText": "", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 53 }, { - "start": 971, - "end": 971, - "replacementText": "let GeneratedImportVar_6 = ESValue.load('./interop_import_js_js');\n" + "start": 958, + "end": 958, + "replacementText": "let GeneratedImportVar_6 = ESValue.load('./interop_import_js_js');\n", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 53 } ], "suggest": "", @@ -207,31 +195,29 @@ "severity": "ERROR" }, { - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 59, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 23, + "line": 22, "column": 1, - "endLine": 23, + "endLine": 22, "endColumn": 59, "problem": "InterOpImportJs", "autofix": [ { - "start": 913, - "end": 971, - "replacementText": "" + "start": 900, + "end": 958, + "replacementText": "", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 59 }, { - "start": 971, - "end": 971, - "replacementText": "let GeneratedImportVar_7 = ESValue.load('./interop_import_js_js');\nlet Wiki = GeneratedImportVar_7.getPropertyByName('Wiki');\nlet Doge = GeneratedImportVar_7.getPropertyByName('Dog');\n" + "start": 958, + "end": 958, + "replacementText": "let GeneratedImportVar_7 = ESValue.load('./interop_import_js_js');\nlet Wiki = GeneratedImportVar_7.getPropertyByName('Wiki');\nlet Doge = GeneratedImportVar_7.getPropertyByName('Dog');\n", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 59 } ], "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.json b/ets2panda/linter/test/interop/interop_import_js.ets.json index c75509e775c31d463f6997a7c8d8ac7ee81ec2bd..ca88f857e960b437dcf767c0ac40be998c8f1236 100755 --- a/ets2panda/linter/test/interop/interop_import_js.ets.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.json @@ -13,76 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 64, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 44, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 57, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 53, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 59, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets index 4aa7a4bbf12a582e7ae13712ed83c712f8d96b2d..80f88726e3970aa7134f5f3cd8df012624cb6668 100644 --- a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -'use static' diff --git a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json index 625afb93e1e3f253b76950465544c88637ab6973..c422eb1668d691782bb71b25d6c92490f9d6ce38 100644 --- a/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js.ets.migrate.json @@ -14,11 +14,21 @@ "limitations under the License." ], "result": [ + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 66, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, { "line": 23, "column": 5, "endLine": 23, - "endColumn": 66, + "endColumn": 58, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -28,7 +38,7 @@ "line": 24, "column": 5, "endLine": 24, - "endColumn": 58, + "endColumn": 57, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -38,7 +48,7 @@ "line": 25, "column": 5, "endLine": 25, - "endColumn": 57, + "endColumn": 66, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -58,7 +68,7 @@ "line": 27, "column": 5, "endLine": 27, - "endColumn": 66, + "endColumn": 58, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -68,7 +78,7 @@ "line": 28, "column": 5, "endLine": 28, - "endColumn": 58, + "endColumn": 62, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -78,7 +88,7 @@ "line": 29, "column": 5, "endLine": 29, - "endColumn": 62, + "endColumn": 56, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -88,7 +98,7 @@ "line": 30, "column": 5, "endLine": 30, - "endColumn": 56, + "endColumn": 66, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -98,7 +108,7 @@ "line": 31, "column": 5, "endLine": 31, - "endColumn": 66, + "endColumn": 58, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -108,7 +118,7 @@ "line": 32, "column": 5, "endLine": 32, - "endColumn": 58, + "endColumn": 71, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -118,7 +128,7 @@ "line": 33, "column": 5, "endLine": 33, - "endColumn": 71, + "endColumn": 66, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -128,7 +138,7 @@ "line": 34, "column": 5, "endLine": 34, - "endColumn": 66, + "endColumn": 56, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -148,7 +158,7 @@ "line": 36, "column": 5, "endLine": 36, - "endColumn": 56, + "endColumn": 58, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -158,7 +168,7 @@ "line": 37, "column": 5, "endLine": 37, - "endColumn": 58, + "endColumn": 56, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -168,7 +178,7 @@ "line": 38, "column": 5, "endLine": 38, - "endColumn": 56, + "endColumn": 58, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -178,16 +188,6 @@ "line": 39, "column": 5, "endLine": 39, - "endColumn": 58, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 40, - "column": 5, - "endLine": 40, "endColumn": 56, "problem": "AnyType", "suggest": "", @@ -195,4 +195,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets b/ets2panda/linter/test/interop/interop_import_js_compare.ets index 496fe91c554cc5de1e7fafcb58c00041a11234a9..bc8146310144db009331d834e1601f295b703c2b 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -'use static' import {foo, m, n} from "./interop_import_js_compare_js" let a = foo.a diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.args.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.args.json index e2b903f0aa82e6ca4108ff67d5272bf49d6c2a5b..571ee6bb76b0cad72a9443db47c2f9d7db474bd0 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.args.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.args.json @@ -1,5 +1,5 @@ { - "copyright": [ + "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.", @@ -12,8 +12,10 @@ "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", "See the License for the specific language governing permissions and", "limitations under the License." - ], - "mode": { - "arkts2": "" - } - } \ No newline at end of file + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.arkts2.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.arkts2.json index 4ce217d61eb50c1edbeaeda10aea16054d519d78..620252abbfd70ab2b6a4a1b9d1c6dfa1eb1c96c4 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 57, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, + "line": 17, "column": 1, - "endLine": 18, + "endLine": 17, "endColumn": 57, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 9, - "endLine": 19, + "endLine": 18, "endColumn": 14, "problem": "InteropObjectProperty", "suggest": "", @@ -49,29 +39,29 @@ "column": 9, "endLine": 19, "endColumn": 14, - "problem": "InteropJsObjectUsage", + "problem": "InteropObjectProperty", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { "line": 20, - "column": 9, + "column": 1, "endLine": 20, - "endColumn": 14, - "problem": "InteropObjectProperty", + "endColumn": 2, + "problem": "InterOpImportJsDataCompare", "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", "severity": "ERROR" }, { "line": 20, - "column": 9, + "column": 5, "endLine": 20, - "endColumn": 14, - "problem": "InteropJsObjectUsage", + "endColumn": 6, + "problem": "InterOpImportJsDataCompare", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", "severity": "ERROR" }, { @@ -106,9 +96,9 @@ }, { "line": 22, - "column": 5, + "column": 6, "endLine": 22, - "endColumn": 6, + "endColumn": 7, "problem": "InterOpImportJsDataCompare", "suggest": "", "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", @@ -136,28 +126,8 @@ }, { "line": 24, - "column": 1, - "endLine": 24, - "endColumn": 2, - "problem": "InterOpImportJsDataCompare", - "suggest": "", - "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 6, - "endLine": 24, - "endColumn": 7, - "problem": "InterOpImportJsDataCompare", - "suggest": "", - "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", - "severity": "ERROR" - }, - { - "line": 25, "column": 5, - "endLine": 25, + "endLine": 24, "endColumn": 6, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +135,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 1, - "endLine": 27, + "endLine": 26, "endColumn": 2, "problem": "InterOpImportJsDataCompare", "suggest": "", @@ -175,9 +145,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 5, - "endLine": 27, + "endLine": 26, "endColumn": 6, "problem": "InterOpImportJsDataCompare", "suggest": "", @@ -185,9 +155,9 @@ "severity": "ERROR" }, { - "line": 28, + "line": 27, "column": 5, - "endLine": 28, + "endLine": 27, "endColumn": 6, "problem": "NumericSemantics", "suggest": "", @@ -195,9 +165,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 5, - "endLine": 30, + "endLine": 29, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -205,9 +175,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 9, - "endLine": 30, + "endLine": 29, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -215,9 +185,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 12, - "endLine": 30, + "endLine": 29, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -225,9 +195,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 16, - "endLine": 30, + "endLine": 29, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -235,9 +205,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 35, "column": 11, - "endLine": 36, + "endLine": 35, "endColumn": 12, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -245,9 +215,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 35, "column": 16, - "endLine": 36, + "endLine": 35, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -255,9 +225,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 35, "column": 22, - "endLine": 36, + "endLine": 35, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -265,9 +235,9 @@ "severity": "ERROR" }, { - "line": 38, + "line": 37, "column": 5, - "endLine": 38, + "endLine": 37, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -275,9 +245,9 @@ "severity": "ERROR" }, { - "line": 38, + "line": 37, "column": 17, - "endLine": 38, + "endLine": 37, "endColumn": 27, "problem": "NumericSemantics", "suggest": "", @@ -285,9 +255,9 @@ "severity": "ERROR" }, { - "line": 44, + "line": 43, "column": 1, - "endLine": 44, + "endLine": 43, "endColumn": 6, "problem": "InterOpImportJsDataCompare", "suggest": "", @@ -295,9 +265,9 @@ "severity": "ERROR" }, { - "line": 44, + "line": 43, "column": 9, - "endLine": 44, + "endLine": 43, "endColumn": 14, "problem": "InterOpImportJsDataCompare", "suggest": "", @@ -305,9 +275,9 @@ "severity": "ERROR" }, { - "line": 44, + "line": 43, "column": 1, - "endLine": 44, + "endLine": 43, "endColumn": 6, "problem": "InteropObjectProperty", "suggest": "", @@ -315,34 +285,14 @@ "severity": "ERROR" }, { - "line": 44, - "column": 1, - "endLine": 44, - "endColumn": 6, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 44, + "line": 43, "column": 9, - "endLine": 44, + "endLine": 43, "endColumn": 14, "problem": "InteropObjectProperty", "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" - }, - { - "line": 44, - "column": 9, - "endLine": 44, - "endColumn": 14, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..2b90e5d9f02599b8a3707341f813b61aef70870f --- /dev/null +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json @@ -0,0 +1,624 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 57, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 607, + "end": 663, + "replacementText": "", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 57 + }, + { + "start": 663, + "end": 663, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_import_js_compare_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\nlet m = GeneratedImportVar_1.getPropertyByName('m');\nlet n = GeneratedImportVar_1.getPropertyByName('n');\n", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 57 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 9, + "endLine": 18, + "endColumn": 14, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 672, + "end": 677, + "replacementText": "foo.getPropertyByName(\"a\")", + "line": 18, + "column": 9, + "endLine": 18, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 9, + "endLine": 19, + "endColumn": 14, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 686, + "end": 691, + "replacementText": "foo.getPropertyByName(\"b\")", + "line": 19, + "column": 9, + "endLine": 19, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 2, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 672, + "end": 677, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 6, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 686, + "end": 691, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 2, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 672, + "end": 677, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 6, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 686, + "end": 691, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 2, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 672, + "end": 677, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 6, + "endLine": 22, + "endColumn": 7, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 686, + "end": 691, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 22, + "column": 6, + "endLine": 22, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 2, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 672, + "end": 677, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 6, + "endLine": 23, + "endColumn": 7, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 686, + "end": 691, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 23, + "column": 6, + "endLine": 23, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 6, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 722, + "end": 723, + "replacementText": "1.0", + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 2, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 725, + "end": 726, + "replacementText": "m.toNumber()", + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 6, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 729, + "end": 730, + "replacementText": "n.toNumber()", + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 6, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 735, + "end": 736, + "replacementText": "1.0", + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 742, + "end": 747, + "replacementText": "x: number = 1", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 9, + "endLine": 29, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 746, + "end": 747, + "replacementText": "1.0", + "line": 29, + "column": 9, + "endLine": 29, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 12, + "endLine": 29, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 749, + "end": 754, + "replacementText": "y: number = 2", + "line": 29, + "column": 12, + "endLine": 29, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 753, + "end": 754, + "replacementText": "2.0", + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12, + "problem": "ObjectLiteralNoContextType", + "autofix": [ + { + "start": 787, + "end": 787, + "replacementText": "interface GeneratedObjectLiteralInterface_1 {\n a: number;\n b: number;\n}\n", + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12 + }, + { + "start": 794, + "end": 794, + "replacementText": ": GeneratedObjectLiteralInterface_1", + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 16, + "endLine": 35, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 802, + "end": 803, + "replacementText": "1.0", + "line": 35, + "column": 16, + "endLine": 35, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 22, + "endLine": 35, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 808, + "end": 809, + "replacementText": "2.0", + "line": 35, + "column": 22, + "endLine": 35, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 818, + "end": 828, + "replacementText": "x2: number = bar.a", + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 17, + "endLine": 37, + "endColumn": 27, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 830, + "end": 840, + "replacementText": "y2: number = bar.b", + "line": 37, + "column": 17, + "endLine": 37, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 881, + "end": 886, + "replacementText": "foo.getPropertyByName(\"a\").toNumber()", + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 889, + "end": 894, + "replacementText": "foo.getPropertyByName(\"b\").toNumber()", + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 881, + "end": 886, + "replacementText": "foo.getPropertyByName(\"a\")", + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 889, + "end": 894, + "replacementText": "foo.getPropertyByName(\"b\")", + "line": 43, + "column": 9, + "endLine": 43, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.json index 25d2c46ecd313256af4ef2245da60133617674c2..e28baca176a2b17f328386775efec64717650b4b 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 57, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 36, + "line": 35, "column": 11, - "endLine": 36, + "endLine": 35, "endColumn": 12, "problem": "ObjectLiteralNoContextType", "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..76633c942c13423af8c35e3e8fc2b0ff3cf00257 --- /dev/null +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let GeneratedImportVar_1 = ESValue.load('./interop_import_js_compare_js'); +let foo = GeneratedImportVar_1.getPropertyByName('foo'); +let m = GeneratedImportVar_1.getPropertyByName('m'); +let n = GeneratedImportVar_1.getPropertyByName('n'); + +let a = foo.getPropertyByName("a") +let b = foo.getPropertyByName("b") +a > b +a < b +a >= b +a <= b +a = 1.0 + +m.toNumber() > n.toNumber() +m = 1.0 + +let x: number = 1.0, y: number = 2.0; +x > y; +x < y; +x >= y; +x <= y; + +interface GeneratedObjectLiteralInterface_1 { + a: number; + b: number; +} +let bar: GeneratedObjectLiteralInterface_1 = { a: 1.0, b: 2.0 }; + +let x2: number = bar.a, y2: number = bar.b; +x2 > y2; +x2 < y2; +x2 >= y2; +x2 <= y2; + +foo.getPropertyByName("a").toNumber() > foo.getPropertyByName("b").toNumber(); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..0ccdec1005fc3e20d0bdcd40db886bc6f12e3e3a --- /dev/null +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.migrate.json @@ -0,0 +1,78 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 74, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 35, + "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/interop/interop_import_js_index.ets b/ets2panda/linter/test/interop/interop_import_js_index.ets index daf1403ab2b8397e96835718602982113a32a281..a4ffabe66033a933d7d064a305ba857dbfe78c7a 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets @@ -12,9 +12,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use static' +import { ff3 } from "./interop_import_js_rules_js" import {foo} from "./interop_import_js_index_js" let arr = foo.arr arr[1] -arr[3] = 4 \ No newline at end of file +arr[3] = 4 + +let arr1 = ff3.arr +let len = arr1.length as number +for (let i = 0; i < arr1.length; ++i) { + console.log(arr1[i]+''); //error + let x = arr1[i] //error + arr1[i] = 0 //error + console.log(arr1[i]+''); //error +} + +for (let element of arr1) { //error + if (element == 8) { + console.log("hi"); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.arkts2.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.arkts2.json index 01e50a4c695af769ff96c170ff87134ac1086f5e..aa54c2f0ca48c0c451cdfb80bd3974658c803602 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.arkts2.json @@ -1,19 +1,33 @@ { + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], "result": [ { - "line": 17, + "line": 15, "column": 1, - "endLine": 17, - "endColumn": 49, - "problem": "ImportAfterStatement", + "endLine": 15, + "endColumn": 51, + "problem": "InterOpImportJs", "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 49, "problem": "InterOpImportJs", "suggest": "", @@ -21,9 +35,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 11, - "endLine": 18, + "endLine": 17, "endColumn": 18, "problem": "InteropObjectProperty", "suggest": "", @@ -32,12 +46,22 @@ }, { "line": 18, - "column": 11, + "column": 1, "endLine": 18, - "endColumn": 18, - "problem": "InteropJsObjectUsage", + "endColumn": 7, + "problem": "RuntimeArrayCheck", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 7, + "problem": "InterOpImportJsIndex", + "suggest": "", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", "severity": "ERROR" }, { @@ -54,61 +78,181 @@ "line": 19, "column": 1, "endLine": 19, - "endColumn": 7, - "problem": "InteropJsObjectTraverseJsInstance", + "endColumn": 11, + "problem": "InterOpImportJsIndex", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", "severity": "ERROR" }, { "line": 19, - "column": 1, + "column": 10, "endLine": 19, - "endColumn": 7, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 12, + "endLine": 21, + "endColumn": 19, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 11, + "endLine": 22, + "endColumn": 22, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 10, + "endLine": 23, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 14, + "endLine": 23, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 32, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 17, + "endLine": 24, + "endColumn": 24, + "problem": "InteropJsObjectTraverseJsInstance", + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 17, + "endLine": 24, + "endColumn": 24, "problem": "InterOpImportJsIndex", "suggest": "", "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 7, - "problem": "RuntimeArrayCheck", + "line": 25, + "column": 13, + "endLine": 25, + "endColumn": 20, + "problem": "InteropJsObjectTraverseJsInstance", "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 7, + "line": 25, + "column": 13, + "endLine": 25, + "endColumn": 20, + "problem": "InterOpImportJsIndex", + "suggest": "", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 12, "problem": "InteropJsObjectTraverseJsInstance", "suggest": "", "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 11, + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 16, "problem": "InterOpImportJsIndex", "suggest": "", "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", "severity": "ERROR" }, { - "line": 20, - "column": 10, - "endLine": 20, - "endColumn": 11, + "line": 26, + "column": 15, + "endLine": 26, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 24, + "problem": "InteropJsObjectTraverseJsInstance", + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 24, + "problem": "InterOpImportJsIndex", + "suggest": "", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 1, + "endLine": 34, + "endColumn": 2, + "problem": "InteropJsObjectTraverseJsInstance", + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 18, + "endLine": 31, + "endColumn": 19, "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/interop/interop_import_js_index.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json index f5e605ca862cb81d76bd021611bd3a80d07b6efc..c9d2b8aee79942e93a8c7a095915ecaf9ad973b2 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json @@ -15,35 +15,59 @@ ], "result": [ { - "line": 17, + "line": 15, "column": 1, - "endLine": 17, - "endColumn": 49, - "problem": "ImportAfterStatement", + "endLine": 15, + "endColumn": 51, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 604, + "end": 654, + "replacementText": "", + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 51 + }, + { + "start": 703, + "end": 703, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_import_js_rules_js');\nlet ff3 = GeneratedImportVar_1.getPropertyByName('ff3');\n", + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 51 + } + ], "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 49, "problem": "InterOpImportJs", "autofix": [ { - "start": 619, - "end": 667, + "start": 655, + "end": 703, "replacementText": "", - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 49 }, { - "start": 667, - "end": 667, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_import_js_index_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n" + "start": 703, + "end": 703, + "replacementText": "let GeneratedImportVar_2 = ESValue.load('./interop_import_js_index_js');\nlet foo = GeneratedImportVar_2.getPropertyByName('foo');\n", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 49 } ], "suggest": "", @@ -51,19 +75,19 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 11, - "endLine": 18, + "endLine": 17, "endColumn": 18, "problem": "InteropObjectProperty", "autofix": [ { - "start": 678, - "end": 685, + "start": 714, + "end": 721, "replacementText": "foo.getPropertyByName(\"arr\")", - "line": 18, + "line": 17, "column": 11, - "endLine": 18, + "endLine": 17, "endColumn": 18 } ], @@ -73,23 +97,33 @@ }, { "line": 18, - "column": 11, + "column": 1, "endLine": 18, - "endColumn": 18, - "problem": "InteropJsObjectUsage", + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 7, + "problem": "InterOpImportJsIndex", "autofix": [ { - "replacementText": "foo.getPropertyByName('arr')", - "start": 678, - "end": 685, + "start": 722, + "end": 728, + "replacementText": "arr.getPropertyByIndex(1)", "line": 18, - "column": 11, + "column": 1, "endLine": 18, - "endColumn": 18 + "endColumn": 7 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", "severity": "ERROR" }, { @@ -106,38 +140,185 @@ "line": 19, "column": 1, "endLine": 19, - "endColumn": 7, - "problem": "InteropJsObjectTraverseJsInstance", + "endColumn": 11, + "problem": "InterOpImportJsIndex", "autofix": [ { - "replacementText": "arr.getPropertyByIndex(1).toNumber()", - "start": 686, - "end": 692, + "start": 729, + "end": 739, + "replacementText": "arr.setPropertyByIndex(3, ESValue.wrap(4))", "line": 19, "column": 1, "endLine": 19, - "endColumn": 7 + "endColumn": 11 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", "severity": "ERROR" }, { "line": 19, - "column": 1, + "column": 10, "endLine": 19, - "endColumn": 7, - "problem": "InterOpImportJsIndex", + "endColumn": 11, + "problem": "NumericSemantics", "autofix": [ { - "start": 686, - "end": 692, - "replacementText": "arr.getPropertyByIndex(1)", + "start": 738, + "end": 739, + "replacementText": "4.0", "line": 19, - "column": 1, + "column": 10, "endLine": 19, - "endColumn": 7 + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 12, + "endLine": 21, + "endColumn": 19, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 752, + "end": 759, + "replacementText": "ff3.getPropertyByName(\"arr\")", + "line": 21, + "column": 12, + "endLine": 21, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 11, + "endLine": 22, + "endColumn": 22, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 770, + "end": 781, + "replacementText": "arr1.getPropertyByName(\"length\")", + "line": 22, + "column": 11, + "endLine": 22, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 10, + "endLine": 23, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 801, + "end": 806, + "replacementText": "i: number = 0", + "line": 23, + "column": 10, + "endLine": 23, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 14, + "endLine": 23, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 805, + "end": 806, + "replacementText": "0.0", + "line": 23, + "column": 14, + "endLine": 23, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 32, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 812, + "end": 823, + "replacementText": "arr1.getPropertyByName(\"length\")", + "line": 23, + "column": 21, + "endLine": 23, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 17, + "endLine": 24, + "endColumn": 24, + "problem": "InteropJsObjectTraverseJsInstance", + "autofix": [ + { + "replacementText": "arr1.getPropertyByIndex(i).toNumber()", + "start": 848, + "end": 855, + "line": 24, + "column": 17, + "endLine": 24, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 17, + "endLine": 24, + "endColumn": 24, + "problem": "InterOpImportJsIndex", + "autofix": [ + { + "start": 848, + "end": 855, + "replacementText": "arr1.getPropertyByIndex(i)", + "line": 24, + "column": 17, + "endLine": 24, + "endColumn": 24 } ], "suggest": "", @@ -145,30 +326,62 @@ "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 7, - "problem": "RuntimeArrayCheck", + "line": 25, + "column": 13, + "endLine": 25, + "endColumn": 20, + "problem": "InteropJsObjectTraverseJsInstance", + "autofix": [ + { + "replacementText": "arr1.getPropertyByIndex(i).toNumber()", + "start": 882, + "end": 889, + "line": 25, + "column": 13, + "endLine": 25, + "endColumn": 20 + } + ], "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 7, + "line": 25, + "column": 13, + "endLine": 25, + "endColumn": 20, + "problem": "InterOpImportJsIndex", + "autofix": [ + { + "start": 882, + "end": 889, + "replacementText": "arr1.getPropertyByIndex(i)", + "line": 25, + "column": 13, + "endLine": 25, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 12, "problem": "InteropJsObjectTraverseJsInstance", "autofix": [ { - "replacementText": "arr.setPropertyByIndex(3, ESValue.wrap(4))", - "start": 693, - "end": 703, - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 7 + "replacementText": "arr1.setPropertyByIndex(i, ESValue.wrap(0 //error\n))", + "start": 903, + "end": 914, + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 12 } ], "suggest": "", @@ -176,16 +389,20 @@ "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 11, + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 16, "problem": "InterOpImportJsIndex", "autofix": [ { - "start": 693, - "end": 703, - "replacementText": "arr.setPropertyByIndex(3, ESValue.wrap(4))" + "start": 903, + "end": 914, + "replacementText": "arr1.setPropertyByIndex(i, ESValue.wrap(0))", + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 16 } ], "suggest": "", @@ -193,20 +410,93 @@ "severity": "ERROR" }, { - "line": 20, - "column": 10, - "endLine": 20, - "endColumn": 11, + "line": 26, + "column": 15, + "endLine": 26, + "endColumn": 16, "problem": "NumericSemantics", "autofix": [ { - "start": 702, - "end": 703, - "replacementText": "4.0", - "line": 20, - "column": 10, - "endLine": 20, - "endColumn": 11 + "start": 913, + "end": 914, + "replacementText": "0.0", + "line": 26, + "column": 15, + "endLine": 26, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 24, + "problem": "InteropJsObjectTraverseJsInstance", + "autofix": [ + { + "replacementText": "arr1.getPropertyByIndex(i).toNumber()", + "start": 940, + "end": 947, + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 24, + "problem": "InterOpImportJsIndex", + "autofix": [ + { + "start": 940, + "end": 947, + "replacementText": "arr1.getPropertyByIndex(i)", + "line": 27, + "column": 17, + "endLine": 27, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 1, + "endLine": 34, + "endColumn": 2, + "problem": "InteropJsObjectTraverseJsInstance", + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 18, + "endLine": 31, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1019, + "end": 1020, + "replacementText": "8.0", + "line": 31, + "column": 18, + "endLine": 31, + "endColumn": 19 } ], "suggest": "", diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.json index 5619e69d7898491f1269e2a8a45cc426ed25574a..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 49, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets index 65d9325e8baee8c6496caf7282ec5ef05eaaf771..8e707c2f6752b0f9a58a59b51ed9fbed9d7bb213 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.ets @@ -12,11 +12,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use static' -let GeneratedImportVar_1 = ESValue.load('./interop_import_js_index_js'); -let foo = GeneratedImportVar_1.getPropertyByName('foo'); + +let GeneratedImportVar_2 = ESValue.load('./interop_import_js_index_js'); +let foo = GeneratedImportVar_2.getPropertyByName('foo'); +let GeneratedImportVar_1 = ESValue.load('./interop_import_js_rules_js'); +let ff3 = GeneratedImportVar_1.getPropertyByName('ff3'); let arr = foo.getPropertyByName("arr") -arr.getPropertyByIndex(1.0).toNumber() -arr.setPropertyByIndex(3.0, ESValue.wrap(4.0)) \ No newline at end of file +arr.getPropertyByIndex(1.0) +arr.setPropertyByIndex(3.0, ESValue.wrap(4.0)) + +let arr1 = ff3.getPropertyByName("arr") +let len: number = arr1.getPropertyByName("length") as number +for (let i: number = 0.0; i < arr1.getPropertyByName("length"); ++i) { + console.log(arr1.getPropertyByIndex(i).toNumber()+''); //error + let x = arr1.getPropertyByIndex(i).toNumber() //error + arr1.setPropertyByIndex(i, ESValue.wrap(0.0 //error +)) //error + console.log(arr1.getPropertyByIndex(i).toNumber()+''); //error +} + +for (let element of arr1) { //error + if (element == 8.0) { + console.log("hi"); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json index 957ef0239d9624c92e24c298a3c7b6e3b2d549ac..526bcedf9d7fab22fb5c38dc894a9f7d71e6da16 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.migrate.json @@ -14,11 +14,21 @@ "limitations under the License." ], "result": [ + { + "line": 16, + "column": 5, + "endLine": 16, + "endColumn": 72, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, { "line": 17, "column": 5, "endLine": 17, - "endColumn": 72, + "endColumn": 56, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -28,6 +38,16 @@ "line": 18, "column": 5, "endLine": 18, + "endColumn": 72, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, "endColumn": 56, "problem": "AnyType", "suggest": "", @@ -35,14 +55,44 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 5, - "endLine": 20, + "endLine": 21, "endColumn": 39, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 9, + "endLine": 29, + "endColumn": 50, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 10, + "endLine": 35, + "endColumn": 17, + "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/interop/interop_import_js_rules.ets b/ets2panda/linter/test/interop/interop_import_js_rules.ets index d7e3b52fcab8ce824276f7f944f792e00a219ad9..d4c110abcf06cbcf3e2626c2640c866038692d3e 100644 --- a/ets2panda/linter/test/interop/interop_import_js_rules.ets +++ b/ets2panda/linter/test/interop/interop_import_js_rules.ets @@ -28,6 +28,7 @@ import { handle } from "./interop_import_js_rules_js" import { expand } from "./interop_import_js_rules_js" import { orange } from "./interop_import_js_rules_js" + if (foo.isGood) {} if (ff1.f1 > 18) { @@ -65,17 +66,27 @@ handle(lambda) class X{a = 1; b= 2; c= 3} expand(new X()) // ERROR expand-static + class Y { str: string = 'str'; bool: boolean = false; } + let testY: Y = { str: "hello", bool: false, } + expand(testY); expand({x: '1', y: "hello", z: false}); + let flag = false; if (orange.isVegetable1 === 123) { flag = true } + +for (let element of arr) { + if (element == 8) { + console.log("hi"); + } +} diff --git a/ets2panda/linter/test/interop/interop_import_js_rules.ets.arkts2.json b/ets2panda/linter/test/interop/interop_import_js_rules.ets.arkts2.json index 299b2732c88f92fb55f66b3b14a65b390fd40dab..abe1b7d5c85525622971996aadf7fc8467a29637 100644 --- a/ets2panda/linter/test/interop/interop_import_js_rules.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_import_js_rules.ets.arkts2.json @@ -195,9 +195,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 5, - "endLine": 31, + "endLine": 32, "endColumn": 15, "problem": "InteropObjectProperty", "suggest": "", @@ -205,9 +205,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 5, - "endLine": 31, + "endLine": 32, "endColumn": 15, "problem": "InteropJsObjectConditionJudgment", "suggest": "", @@ -215,9 +215,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 5, - "endLine": 33, + "endLine": 34, "endColumn": 11, "problem": "InterOpImportJsDataCompare", "suggest": "", @@ -225,9 +225,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 5, - "endLine": 33, + "endLine": 34, "endColumn": 11, "problem": "InteropObjectProperty", "suggest": "", @@ -235,9 +235,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 5, - "endLine": 33, + "endLine": 34, "endColumn": 11, "problem": "InteropJsObjectConditionJudgment", "suggest": "", @@ -245,9 +245,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 14, - "endLine": 33, + "endLine": 34, "endColumn": 16, "problem": "NumericSemantics", "suggest": "", @@ -255,9 +255,9 @@ "severity": "ERROR" }, { - "line": 37, + "line": 38, "column": 1, - "endLine": 37, + "endLine": 38, "endColumn": 21, "problem": "InteropJsObjectInheritance", "suggest": "", @@ -265,9 +265,9 @@ "severity": "ERROR" }, { - "line": 41, + "line": 42, "column": 1, - "endLine": 41, + "endLine": 42, "endColumn": 21, "problem": "InteropJsObjectInheritance", "suggest": "", @@ -275,19 +275,19 @@ "severity": "ERROR" }, { - "line": 44, + "line": 45, "column": 3, - "endLine": 44, + "endLine": 45, "endColumn": 8, "problem": "InteropJSFunctionInvoke", "suggest": "", - "rule": "Trying to catch JS errors is not permitted (arkts-interop-js2s-js-exception)", + "rule": "ArkTS1.2 cannot catch a non Error instance thrown from JS code (arkts-interop-js2s-js-exception)", "severity": "ERROR" }, { - "line": 44, + "line": 45, "column": 3, - "endLine": 44, + "endLine": 45, "endColumn": 8, "problem": "CallJSFunction", "suggest": "", @@ -295,19 +295,9 @@ "severity": "ERROR" }, { - "line": 45, - "column": 3, - "endLine": 47, - "endColumn": 2, - "problem": "TsLikeCatchType", - "suggest": "", - "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", - "severity": "ERROR" - }, - { - "line": 49, + "line": 50, "column": 11, - "endLine": 49, + "endLine": 50, "endColumn": 18, "problem": "InteropObjectProperty", "suggest": "", @@ -315,39 +305,19 @@ "severity": "ERROR" }, { - "line": 49, - "column": 11, - "endLine": 49, - "endColumn": 18, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 50, + "line": 51, "column": 11, - "endLine": 50, + "endLine": 51, "endColumn": 21, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 53, - "column": 3, - "endLine": 53, - "endColumn": 9, - "problem": "RuntimeArrayCheck", + "problem": "InteropObjectProperty", "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { - "line": 51, + "line": 52, "column": 10, - "endLine": 51, + "endLine": 52, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -355,9 +325,9 @@ "severity": "ERROR" }, { - "line": 51, + "line": 52, "column": 14, - "endLine": 51, + "endLine": 52, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -365,9 +335,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 11, - "endLine": 52, + "endLine": 53, "endColumn": 17, "problem": "RuntimeArrayCheck", "suggest": "", @@ -375,9 +345,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 11, - "endLine": 52, + "endLine": 53, "endColumn": 17, "problem": "InteropJsObjectTraverseJsInstance", "suggest": "", @@ -385,9 +355,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 11, - "endLine": 52, + "endLine": 53, "endColumn": 17, "problem": "InterOpImportJsIndex", "suggest": "", @@ -395,9 +365,19 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 3, - "endLine": 53, + "endLine": 54, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 3, + "endLine": 54, "endColumn": 9, "problem": "InteropJsObjectTraverseJsInstance", "suggest": "", @@ -405,9 +385,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 3, - "endLine": 53, + "endLine": 54, "endColumn": 13, "problem": "InterOpImportJsIndex", "suggest": "", @@ -415,9 +395,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 12, - "endLine": 53, + "endLine": 54, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", @@ -425,19 +405,19 @@ "severity": "ERROR" }, { - "line": 63, + "line": 64, "column": 8, - "endLine": 63, + "endLine": 64, "endColumn": 12, "problem": "InteropJsObjectCallStaticFunc", "suggest": "", "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)", - "severity": "ERROR" + "severity": "WARNING" }, { - "line": 63, + "line": 64, "column": 1, - "endLine": 63, + "endLine": 64, "endColumn": 13, "problem": "CallJSFunction", "suggest": "", @@ -445,19 +425,19 @@ "severity": "ERROR" }, { - "line": 64, + "line": 65, "column": 8, - "endLine": 64, + "endLine": 65, "endColumn": 14, "problem": "InteropJsObjectCallStaticFunc", "suggest": "", "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)", - "severity": "ERROR" + "severity": "WARNING" }, { - "line": 64, + "line": 65, "column": 1, - "endLine": 64, + "endLine": 65, "endColumn": 15, "problem": "CallJSFunction", "suggest": "", @@ -465,9 +445,9 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 9, - "endLine": 66, + "endLine": 67, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -475,9 +455,9 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 13, - "endLine": 66, + "endLine": 67, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -485,9 +465,9 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 16, - "endLine": 66, + "endLine": 67, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -495,9 +475,9 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 19, - "endLine": 66, + "endLine": 67, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -505,9 +485,9 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 22, - "endLine": 66, + "endLine": 67, "endColumn": 26, "problem": "NumericSemantics", "suggest": "", @@ -515,9 +495,9 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 25, - "endLine": 66, + "endLine": 67, "endColumn": 26, "problem": "NumericSemantics", "suggest": "", @@ -525,9 +505,9 @@ "severity": "ERROR" }, { - "line": 67, + "line": 68, "column": 8, - "endLine": 67, + "endLine": 68, "endColumn": 15, "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", @@ -535,9 +515,9 @@ "severity": "ERROR" }, { - "line": 67, + "line": 68, "column": 1, - "endLine": 67, + "endLine": 68, "endColumn": 16, "problem": "CallJSFunction", "suggest": "", @@ -545,9 +525,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 80, "column": 8, - "endLine": 76, + "endLine": 80, "endColumn": 13, "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", @@ -555,9 +535,9 @@ "severity": "ERROR" }, { - "line": 76, + "line": 80, "column": 1, - "endLine": 76, + "endLine": 80, "endColumn": 14, "problem": "CallJSFunction", "suggest": "", @@ -565,9 +545,9 @@ "severity": "ERROR" }, { - "line": 77, + "line": 81, "column": 8, - "endLine": 77, + "endLine": 81, "endColumn": 38, "problem": "InteropJsObjectExpandStaticInstance", "suggest": "", @@ -575,9 +555,9 @@ "severity": "ERROR" }, { - "line": 77, + "line": 81, "column": 1, - "endLine": 77, + "endLine": 81, "endColumn": 39, "problem": "CallJSFunction", "suggest": "", @@ -585,9 +565,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 84, "column": 5, - "endLine": 79, + "endLine": 84, "endColumn": 32, "problem": "InteropEqualityJudgment", "suggest": "", @@ -595,9 +575,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 84, "column": 5, - "endLine": 79, + "endLine": 84, "endColumn": 24, "problem": "InteropObjectProperty", "suggest": "", @@ -605,24 +585,34 @@ "severity": "ERROR" }, { - "line": 79, - "column": 5, - "endLine": 79, - "endColumn": 24, - "problem": "InteropJsObjectUsage", + "line": 84, + "column": 29, + "endLine": 84, + "endColumn": 32, + "problem": "NumericSemantics", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 79, - "column": 29, - "endLine": 79, - "endColumn": 32, + "line": 88, + "column": 1, + "endLine": 92, + "endColumn": 2, + "problem": "InteropJsObjectTraverseJsInstance", + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 18, + "endLine": 89, + "endColumn": 19, "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/interop/interop_import_js_rules.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json index 4e7f1b6c7acc8979fbd86d4ce8eb5aa2b31f59bd..b44bc6c370bb96f878c98831d18e2206a3150a08 100644 --- a/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json @@ -1,1149 +1,1139 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51, - "problem": "InterOpImportJs", - "autofix": [ + "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": [ { - "start": 619, - "end": 669, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51 + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 51, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_import_js_rules_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 51 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56, - "problem": "InterOpImportJs", - "autofix": [ + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 51, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 619, + "end": 669, + "replacementText": "", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 51 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_import_js_rules_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 51 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 670, - "end": 725, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56 + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 56, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_2 = ESValue.load('./interop_import_js_rules_js');\nlet ff1 = GeneratedImportVar_2.getPropertyByName('ff1');\nlet ff2 = GeneratedImportVar_2.getPropertyByName('ff2');\n", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 56 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49, - "problem": "InterOpImportJs", - "autofix": [ + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 56, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 670, + "end": 725, + "replacementText": "", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 56 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_2 = ESValue.load('./interop_import_js_rules_js');\nlet ff1 = GeneratedImportVar_2.getPropertyByName('ff1');\nlet ff2 = GeneratedImportVar_2.getPropertyByName('ff2');\n", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 56 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 727, - "end": 775, - "replacementText": "", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49 + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 49, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_3 = ESValue.load('./interop_import_js_rules_js');\nlet A = GeneratedImportVar_3.getPropertyByName('A');\n", - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 49 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49, - "problem": "InterOpImportJs", - "autofix": [ + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 49, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 727, + "end": 775, + "replacementText": "", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 49 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_3 = ESValue.load('./interop_import_js_rules_js');\nlet A = GeneratedImportVar_3.getPropertyByName('A');\n", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 49 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 776, - "end": 824, - "replacementText": "", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49 + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 49, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_4 = ESValue.load('./interop_import_js_rules_js');\nlet C = GeneratedImportVar_4.getPropertyByName('C');\n", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 49 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51, - "problem": "InterOpImportJs", - "autofix": [ + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 49, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 776, + "end": 824, + "replacementText": "", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 49 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_4 = ESValue.load('./interop_import_js_rules_js');\nlet C = GeneratedImportVar_4.getPropertyByName('C');\n", + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 49 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 826, - "end": 876, - "replacementText": "", - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51 + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 51, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_5 = ESValue.load('./interop_import_js_rules_js');\nlet ff3 = GeneratedImportVar_5.getPropertyByName('ff3');\n", - "line": 23, - "column": 1, - "endLine": 23, - "endColumn": 51 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51, - "problem": "InterOpImportJs", - "autofix": [ + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 51, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 826, + "end": 876, + "replacementText": "", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 51 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_5 = ESValue.load('./interop_import_js_rules_js');\nlet ff3 = GeneratedImportVar_5.getPropertyByName('ff3');\n", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 51 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 878, - "end": 928, - "replacementText": "", - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51 + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 51, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_6 = ESValue.load('./interop_import_js_rules_js');\nlet ff4 = GeneratedImportVar_6.getPropertyByName('ff4');\n", - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 51 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54, - "problem": "InterOpImportJs", - "autofix": [ + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 51, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 878, + "end": 928, + "replacementText": "", + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 51 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_6 = ESValue.load('./interop_import_js_rules_js');\nlet ff4 = GeneratedImportVar_6.getPropertyByName('ff4');\n", + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 51 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 930, - "end": 983, - "replacementText": "", - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54 + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 54, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_7 = ESValue.load('./interop_import_js_rules_js');\nlet handle = GeneratedImportVar_7.getPropertyByName('handle');\n", - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 54 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54, - "problem": "InterOpImportJs", - "autofix": [ + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 54, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 930, + "end": 983, + "replacementText": "", + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 54 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_7 = ESValue.load('./interop_import_js_rules_js');\nlet handle = GeneratedImportVar_7.getPropertyByName('handle');\n", + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 54 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 985, - "end": 1038, - "replacementText": "", - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54 + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 54, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_8 = ESValue.load('./interop_import_js_rules_js');\nlet expand = GeneratedImportVar_8.getPropertyByName('expand');\n", - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 54 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54, - "problem": "InterOpImportJs", - "autofix": [ + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 54, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 985, + "end": 1038, + "replacementText": "", + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 54 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_8 = ESValue.load('./interop_import_js_rules_js');\nlet expand = GeneratedImportVar_8.getPropertyByName('expand');\n", + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 54 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 1039, - "end": 1092, - "replacementText": "", - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54 + "line": 30, + "column": 1, + "endLine": 30, + "endColumn": 54, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" }, { - "start": 1092, - "end": 1092, - "replacementText": "let GeneratedImportVar_9 = ESValue.load('./interop_import_js_rules_js');\nlet orange = GeneratedImportVar_9.getPropertyByName('orange');\n", - "line": 30, - "column": 1, - "endLine": 30, - "endColumn": 54 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 31, - "column": 5, - "endLine": 31, - "endColumn": 15, - "problem": "InteropObjectProperty", - "autofix": [ + "line": 30, + "column": 1, + "endLine": 30, + "endColumn": 54, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 1039, + "end": 1092, + "replacementText": "", + "line": 30, + "column": 1, + "endLine": 30, + "endColumn": 54 + }, + { + "start": 1092, + "end": 1092, + "replacementText": "let GeneratedImportVar_9 = ESValue.load('./interop_import_js_rules_js');\nlet orange = GeneratedImportVar_9.getPropertyByName('orange');\n", + "line": 30, + "column": 1, + "endLine": 30, + "endColumn": 54 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { - "start": 1097, - "end": 1107, - "replacementText": "foo.getPropertyByName(\"isGood\")", - "line": 31, - "column": 5, - "endLine": 31, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 31, - "column": 5, - "endLine": 31, - "endColumn": 15, - "problem": "InteropJsObjectConditionJudgment", - "autofix": [ + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 15, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1098, + "end": 1108, + "replacementText": "foo.getPropertyByName(\"isGood\")", + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { - "replacementText": "foo.getPropertyByName('isGood').toBoolean()", - "start": 1097, - "end": 1107, - "line": 31, - "column": 5, - "endLine": 31, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 5, - "endLine": 33, - "endColumn": 11, - "problem": "InterOpImportJsDataCompare", - "suggest": "", - "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 5, - "endLine": 33, - "endColumn": 11, - "problem": "InteropObjectProperty", - "autofix": [ + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 15, + "problem": "InteropJsObjectConditionJudgment", + "autofix": [ + { + "replacementText": "foo.getPropertyByName('isGood').toBoolean()", + "start": 1098, + "end": 1108, + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)", + "severity": "ERROR" + }, { - "start": 1117, - "end": 1123, - "replacementText": "ff1.getPropertyByName(\"f1\")", - "line": 33, - "column": 5, - "endLine": 33, - "endColumn": 11 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 5, - "endLine": 33, - "endColumn": 11, - "problem": "InteropJsObjectConditionJudgment", - "autofix": [ + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11, + "problem": "InterOpImportJsDataCompare", + "autofix": [ + { + "start": 1118, + "end": 1124, + "replacementText": "ff1.getPropertyByName(\"f1\").toNumber()", + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", + "severity": "ERROR" + }, { - "replacementText": "ff1.getPropertyByName('f1').toNumber()", - "start": 1117, - "end": 1123, - "line": 33, - "column": 5, - "endLine": 33, - "endColumn": 11 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 14, - "endLine": 33, - "endColumn": 16, - "problem": "NumericSemantics", - "autofix": [ + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1118, + "end": 1124, + "replacementText": "ff1.getPropertyByName(\"f1\")", + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { - "start": 1126, - "end": 1128, - "replacementText": "18.0", - "line": 33, - "column": 14, - "endLine": 33, - "endColumn": 16 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 37, - "column": 1, - "endLine": 37, - "endColumn": 21, - "problem": "InteropJsObjectInheritance", - "suggest": "", - "rule": "Direct inheritance of interop JS classes is not supported (arkts-interop-js2s-inherit-js-class)", - "severity": "ERROR" - }, - { - "line": 41, - "column": 1, - "endLine": 41, - "endColumn": 21, - "problem": "InteropJsObjectInheritance", - "suggest": "", - "rule": "Direct inheritance of interop JS classes is not supported (arkts-interop-js2s-inherit-js-class)", - "severity": "ERROR" - }, - { - "line": 44, - "column": 3, - "endLine": 44, - "endColumn": 8, - "problem": "InteropJSFunctionInvoke", - "suggest": "", - "rule": "Trying to catch JS errors is not permitted (arkts-interop-js2s-js-exception)", - "severity": "ERROR" - }, - { - "line": 44, - "column": 3, - "endLine": 44, - "endColumn": 8, - "problem": "CallJSFunction", - "autofix": [ + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11, + "problem": "InteropJsObjectConditionJudgment", + "autofix": [ + { + "replacementText": "ff1.getPropertyByName('f1').toNumber()", + "start": 1118, + "end": 1124, + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)", + "severity": "ERROR" + }, { - "start": 1288, - "end": 1293, - "replacementText": "ff4.invoke()", - "line": 44, - "column": 3, - "endLine": 44, - "endColumn": 8 - } - ], - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 45, - "column": 3, - "endLine": 47, - "endColumn": 2, - "problem": "TsLikeCatchType", - "suggest": "", - "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", - "severity": "ERROR" - }, - { - "line": 49, - "column": 11, - "endLine": 49, - "endColumn": 18, - "problem": "InteropObjectProperty", - "autofix": [ + "line": 34, + "column": 14, + "endLine": 34, + "endColumn": 16, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1127, + "end": 1129, + "replacementText": "18.0", + "line": 34, + "column": 14, + "endLine": 34, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "start": 1343, - "end": 1350, - "replacementText": "ff3.getPropertyByName(\"arr\")", - "line": 49, - "column": 11, - "endLine": 49, - "endColumn": 18 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 49, - "column": 11, - "endLine": 49, - "endColumn": 18, - "problem": "InteropJsObjectUsage", - "autofix": [ + "line": 38, + "column": 1, + "endLine": 38, + "endColumn": 21, + "problem": "InteropJsObjectInheritance", + "suggest": "", + "rule": "Direct inheritance of interop JS classes is not supported (arkts-interop-js2s-inherit-js-class)", + "severity": "ERROR" + }, { - "replacementText": "ff3.getPropertyByName('arr')", - "start": 1343, - "end": 1350, - "line": 49, - "column": 11, - "endLine": 49, - "endColumn": 18 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 50, - "column": 11, - "endLine": 50, - "endColumn": 21, - "problem": "InteropJsObjectUsage", - "autofix": [ + "line": 42, + "column": 1, + "endLine": 42, + "endColumn": 21, + "problem": "InteropJsObjectInheritance", + "suggest": "", + "rule": "Direct inheritance of interop JS classes is not supported (arkts-interop-js2s-inherit-js-class)", + "severity": "ERROR" + }, { - "replacementText": "arr.getPropertyByName('length').toNumber()", - "start": 1361, - "end": 1381, - "line": 50, - "column": 11, - "endLine": 50, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 53, - "column": 3, - "endLine": 53, - "endColumn": 9, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 51, - "column": 10, - "endLine": 51, - "endColumn": 15, - "problem": "NumericSemantics", - "autofix": [ + "line": 45, + "column": 3, + "endLine": 45, + "endColumn": 8, + "problem": "InteropJSFunctionInvoke", + "suggest": "", + "rule": "ArkTS1.2 cannot catch a non Error instance thrown from JS code (arkts-interop-js2s-js-exception)", + "severity": "ERROR" + }, { - "start": 1391, - "end": 1396, - "replacementText": "i: number = 0", - "line": 51, - "column": 10, - "endLine": 51, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 51, - "column": 14, - "endLine": 51, - "endColumn": 15, - "problem": "NumericSemantics", - "autofix": [ + "line": 45, + "column": 3, + "endLine": 45, + "endColumn": 8, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 1289, + "end": 1294, + "replacementText": "ff4.invoke()", + "line": 45, + "column": 3, + "endLine": 45, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, { - "start": 1395, - "end": 1396, - "replacementText": "0.0", - "line": 51, - "column": 14, - "endLine": 51, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 52, - "column": 11, - "endLine": 52, - "endColumn": 17, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, - { - "line": 52, - "column": 11, - "endLine": 52, - "endColumn": 17, - "problem": "InteropJsObjectTraverseJsInstance", - "autofix": [ + "line": 50, + "column": 11, + "endLine": 50, + "endColumn": 18, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1344, + "end": 1351, + "replacementText": "ff3.getPropertyByName(\"arr\")", + "line": 50, + "column": 11, + "endLine": 50, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { - "replacementText": "arr.getPropertyByIndex(i).toNumber()", - "start": 1424, - "end": 1430, - "line": 52, - "column": 11, - "endLine": 52, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", - "severity": "ERROR" - }, - { - "line": 52, - "column": 11, - "endLine": 52, - "endColumn": 17, - "problem": "InterOpImportJsIndex", - "autofix": [ + "line": 51, + "column": 11, + "endLine": 51, + "endColumn": 21, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1362, + "end": 1372, + "replacementText": "arr.getPropertyByName(\"length\")", + "line": 51, + "column": 11, + "endLine": 51, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { - "start": 1424, - "end": 1430, - "replacementText": "arr.getPropertyByIndex(i)", - "line": 52, - "column": 11, - "endLine": 52, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", - "severity": "ERROR" - }, - { - "line": 53, - "column": 3, - "endLine": 53, - "endColumn": 9, - "problem": "InteropJsObjectTraverseJsInstance", - "autofix": [ + "line": 52, + "column": 10, + "endLine": 52, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1392, + "end": 1397, + "replacementText": "i: number = 0", + "line": 52, + "column": 10, + "endLine": 52, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "replacementText": "arr.setPropertyByIndex(i, ESValue.wrap(0))", - "start": 1433, - "end": 1443, - "line": 53, - "column": 3, - "endLine": 53, - "endColumn": 9 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", - "severity": "ERROR" - }, - { - "line": 53, - "column": 3, - "endLine": 53, - "endColumn": 13, - "problem": "InterOpImportJsIndex", - "autofix": [ + "line": 52, + "column": 14, + "endLine": 52, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1396, + "end": 1397, + "replacementText": "0.0", + "line": 52, + "column": 14, + "endLine": 52, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "start": 1433, - "end": 1443, - "replacementText": "arr.setPropertyByIndex(i, ESValue.wrap(0))", - "line": 53, - "column": 3, - "endLine": 53, - "endColumn": 13 - } - ], - "suggest": "", - "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", - "severity": "ERROR" - }, - { - "line": 53, - "column": 12, - "endLine": 53, - "endColumn": 13, - "problem": "NumericSemantics", - "autofix": [ + "line": 53, + "column": 11, + "endLine": 53, + "endColumn": 17, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { - "start": 1442, - "end": 1443, - "replacementText": "0.0", - "line": 53, - "column": 12, - "endLine": 53, - "endColumn": 13 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 63, - "column": 8, - "endLine": 63, - "endColumn": 12, - "problem": "InteropJsObjectCallStaticFunc", - "suggest": "", - "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)", - "severity": "ERROR" - }, - { - "line": 63, - "column": 1, - "endLine": 63, - "endColumn": 13, - "problem": "CallJSFunction", - "autofix": [ + "line": 53, + "column": 11, + "endLine": 53, + "endColumn": 17, + "problem": "InteropJsObjectTraverseJsInstance", + "autofix": [ + { + "replacementText": "arr.getPropertyByIndex(i).toNumber()", + "start": 1425, + "end": 1431, + "line": 53, + "column": 11, + "endLine": 53, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, { - "start": 1544, - "end": 1556, - "replacementText": "handle.invoke(ESValue.wrap(foo2))", - "line": 63, - "column": 1, - "endLine": 63, - "endColumn": 13 - } - ], - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 64, - "column": 8, - "endLine": 64, - "endColumn": 14, - "problem": "InteropJsObjectCallStaticFunc", - "suggest": "", - "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)", - "severity": "ERROR" - }, - { - "line": 64, - "column": 1, - "endLine": 64, - "endColumn": 15, - "problem": "CallJSFunction", - "autofix": [ + "line": 53, + "column": 11, + "endLine": 53, + "endColumn": 17, + "problem": "InterOpImportJsIndex", + "autofix": [ + { + "start": 1425, + "end": 1431, + "replacementText": "arr.getPropertyByIndex(i)", + "line": 53, + "column": 11, + "endLine": 53, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", + "severity": "ERROR" + }, { - "start": 1557, - "end": 1571, - "replacementText": "handle.invoke(ESValue.wrap(lambda))", - "line": 64, - "column": 1, - "endLine": 64, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 9, - "endLine": 66, - "endColumn": 15, - "problem": "NumericSemantics", - "autofix": [ + "line": 54, + "column": 3, + "endLine": 54, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { - "start": 1581, - "end": 1587, - "replacementText": "a: number = 1;", - "line": 66, - "column": 9, - "endLine": 66, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 13, - "endLine": 66, - "endColumn": 14, - "problem": "NumericSemantics", - "autofix": [ + "line": 54, + "column": 3, + "endLine": 54, + "endColumn": 9, + "problem": "InteropJsObjectTraverseJsInstance", + "autofix": [ + { + "replacementText": "arr.setPropertyByIndex(i, ESValue.wrap(0))", + "start": 1434, + "end": 1444, + "line": 54, + "column": 3, + "endLine": 54, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, { - "start": 1585, - "end": 1586, - "replacementText": "1.0", - "line": 66, - "column": 13, - "endLine": 66, - "endColumn": 14 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 16, - "endLine": 66, - "endColumn": 21, - "problem": "NumericSemantics", - "autofix": [ + "line": 54, + "column": 3, + "endLine": 54, + "endColumn": 13, + "problem": "InterOpImportJsIndex", + "autofix": [ + { + "start": 1434, + "end": 1444, + "replacementText": "arr.setPropertyByIndex(i, ESValue.wrap(0))", + "line": 54, + "column": 3, + "endLine": 54, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Interop objects can't be indexed directly (arkts-interop-js2s-access-js-index)", + "severity": "ERROR" + }, { - "start": 1588, - "end": 1593, - "replacementText": "b: number = 2;", - "line": 66, - "column": 16, - "endLine": 66, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 19, - "endLine": 66, - "endColumn": 20, - "problem": "NumericSemantics", - "autofix": [ + "line": 54, + "column": 12, + "endLine": 54, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1443, + "end": 1444, + "replacementText": "0.0", + "line": 54, + "column": 12, + "endLine": 54, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "start": 1591, - "end": 1592, - "replacementText": "2.0", - "line": 66, - "column": 19, - "endLine": 66, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 22, - "endLine": 66, - "endColumn": 26, - "problem": "NumericSemantics", - "autofix": [ + "line": 64, + "column": 8, + "endLine": 64, + "endColumn": 12, + "problem": "InteropJsObjectCallStaticFunc", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)", + "severity": "WARNING" + }, { - "start": 1594, - "end": 1598, - "replacementText": "c: number = 3;", - "line": 66, - "column": 22, - "endLine": 66, - "endColumn": 26 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 25, - "endLine": 66, - "endColumn": 26, - "problem": "NumericSemantics", - "autofix": [ + "line": 64, + "column": 1, + "endLine": 64, + "endColumn": 13, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 1545, + "end": 1557, + "replacementText": "handle.invoke(ESValue.wrap(foo2))", + "line": 64, + "column": 1, + "endLine": 64, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, { - "start": 1597, - "end": 1598, - "replacementText": "3.0", - "line": 66, - "column": 25, - "endLine": 66, - "endColumn": 26 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 67, - "column": 8, - "endLine": 67, - "endColumn": 15, - "problem": "InteropJsObjectExpandStaticInstance", - "suggest": "", - "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", - "severity": "ERROR" - }, - { - "line": 67, - "column": 1, - "endLine": 67, - "endColumn": 16, - "problem": "CallJSFunction", - "autofix": [ + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 14, + "problem": "InteropJsObjectCallStaticFunc", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-call-static-function)", + "severity": "WARNING" + }, { - "start": 1600, - "end": 1615, - "replacementText": "expand.invoke(ESValue.wrap(new X()))", - "line": 67, - "column": 1, - "endLine": 67, - "endColumn": 16 - } - ], - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 76, - "column": 8, - "endLine": 76, - "endColumn": 13, - "problem": "InteropJsObjectExpandStaticInstance", - "suggest": "", - "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", - "severity": "ERROR" - }, - { - "line": 76, - "column": 1, - "endLine": 76, - "endColumn": 14, - "problem": "CallJSFunction", - "autofix": [ + "line": 65, + "column": 1, + "endLine": 65, + "endColumn": 15, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 1558, + "end": 1572, + "replacementText": "handle.invoke(ESValue.wrap(lambda))", + "line": 65, + "column": 1, + "endLine": 65, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, { - "start": 1749, - "end": 1762, - "replacementText": "expand.invoke(ESValue.wrap(testY))", - "line": 76, - "column": 1, - "endLine": 76, - "endColumn": 14 - } - ], - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 77, - "column": 8, - "endLine": 77, - "endColumn": 38, - "problem": "InteropJsObjectExpandStaticInstance", - "suggest": "", - "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", - "severity": "ERROR" - }, - { - "line": 77, - "column": 1, - "endLine": 77, - "endColumn": 39, - "problem": "CallJSFunction", - "autofix": [ + "line": 67, + "column": 9, + "endLine": 67, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1582, + "end": 1588, + "replacementText": "a: number = 1;", + "line": 67, + "column": 9, + "endLine": 67, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "start": 1764, - "end": 1802, - "replacementText": "expand.invoke(ESValue.wrap({x: '1', y: \"hello\", z: false}))", - "line": 77, - "column": 1, - "endLine": 77, - "endColumn": 39 - } - ], - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 5, - "endLine": 79, - "endColumn": 32, - "problem": "InteropEqualityJudgment", - "autofix": [ + "line": 67, + "column": 13, + "endLine": 67, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1586, + "end": 1587, + "replacementText": "1.0", + "line": 67, + "column": 13, + "endLine": 67, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "start": 1826, - "end": 1853, - "replacementText": "orange.isVegetable1.areStrictlyEqual(123)", - "line": 79, - "column": 5, - "endLine": 79, - "endColumn": 32 - } - ], - "suggest": "", - "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 5, - "endLine": 79, - "endColumn": 24, - "problem": "InteropObjectProperty", - "autofix": [ + "line": 67, + "column": 16, + "endLine": 67, + "endColumn": 21, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1589, + "end": 1594, + "replacementText": "b: number = 2;", + "line": 67, + "column": 16, + "endLine": 67, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "start": 1826, - "end": 1845, - "replacementText": "orange.getPropertyByName(\"isVegetable1\")", - "line": 79, - "column": 5, - "endLine": 79, - "endColumn": 24 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 5, - "endLine": 79, - "endColumn": 24, - "problem": "InteropJsObjectUsage", - "autofix": [ + "line": 67, + "column": 19, + "endLine": 67, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1592, + "end": 1593, + "replacementText": "2.0", + "line": 67, + "column": 19, + "endLine": 67, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { - "replacementText": "orange.getPropertyByName('isVegetable1').toNumber()", - "start": 1826, - "end": 1845, - "line": 79, - "column": 5, - "endLine": 79, - "endColumn": 24 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 79, - "column": 29, - "endLine": 79, - "endColumn": 32, - "problem": "NumericSemantics", - "autofix": [ + "line": 67, + "column": 22, + "endLine": 67, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1595, + "end": 1599, + "replacementText": "c: number = 3;", + "line": 67, + "column": 22, + "endLine": 67, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 25, + "endLine": 67, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1598, + "end": 1599, + "replacementText": "3.0", + "line": 67, + "column": 25, + "endLine": 67, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 8, + "endLine": 68, + "endColumn": 15, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 16, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 1601, + "end": 1616, + "replacementText": "expand.invoke(ESValue.wrap(new X()))", + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 8, + "endLine": 80, + "endColumn": 13, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 1, + "endLine": 80, + "endColumn": 14, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 1753, + "end": 1766, + "replacementText": "expand.invoke(ESValue.wrap(testY))", + "line": 80, + "column": 1, + "endLine": 80, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 8, + "endLine": 81, + "endColumn": 38, + "problem": "InteropJsObjectExpandStaticInstance", + "suggest": "", + "rule": "Direct usage of interop JS functions is not supported (arkts-interop-js2s-js-expand-static-instance)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 39, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 1768, + "end": 1806, + "replacementText": "expand.invoke(ESValue.wrap({x: '1', y: \"hello\", z: false}))", + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 39 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 5, + "endLine": 84, + "endColumn": 32, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1831, + "end": 1858, + "replacementText": "orange.isVegetable1.areStrictlyEqual(123)", + "line": 84, + "column": 5, + "endLine": 84, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 5, + "endLine": 84, + "endColumn": 24, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1831, + "end": 1850, + "replacementText": "orange.getPropertyByName(\"isVegetable1\")", + "line": 84, + "column": 5, + "endLine": 84, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 29, + "endLine": 84, + "endColumn": 32, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1855, + "end": 1858, + "replacementText": "123.0", + "line": 84, + "column": 29, + "endLine": 84, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 92, + "endColumn": 2, + "problem": "InteropJsObjectTraverseJsInstance", + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-traverse-js-instance)", + "severity": "ERROR" + }, { - "start": 1850, - "end": 1853, - "replacementText": "123.0", - "line": 79, - "column": 29, - "endLine": 79, - "endColumn": 32 + "line": 89, + "column": 18, + "endLine": 89, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1921, + "end": 1922, + "replacementText": "8.0", + "line": 89, + "column": 18, + "endLine": 89, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" } - ], - "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/interop/interop_import_js_rules.ets.json b/ets2panda/linter/test/interop/interop_import_js_rules.ets.json index 097539546e670b2be7a38f6e744498ccf306b277..ab212bc3f3999cd0aab878e852fd6fdaad9d1c5f 100644 --- a/ets2panda/linter/test/interop/interop_import_js_rules.ets.json +++ b/ets2panda/linter/test/interop/interop_import_js_rules.ets.json @@ -1,18 +1,18 @@ { - "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." - ], + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], "result": [ { "line": 17, diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets b/ets2panda/linter/test/interop/interop_import_typeof_js.ets old mode 100755 new mode 100644 index 3c4c0728f9b58e0b9753a086eb6110913b0a1170..b8941c7ac57d8a483e829d2f30ae7460555a8495 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets @@ -12,8 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use static' + import myAaa,{ClassA,Dog,Person,Wiki} from "./interop_import_js_js"; import { Dog as Doge } from './interop_import_js_js'; import { Wiki as wiki } from './interop_import_js_js'; diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.arkts2.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.arkts2.json old mode 100755 new mode 100644 index 07bd2108126e7d5c111d51ef715798f359641175..e1fc6d18dd6d307f7f56be2cebc081176947a3fb --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.arkts2.json @@ -1,488 +1,438 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 69, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 69, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 54, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 54, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 55, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 55, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 15, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 11, - "endLine": 22, - "endColumn": 18, - "problem": "CallJSFunction", - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 1, - "endLine": 24, - "endColumn": 11, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 19, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 8, - "endLine": 25, - "endColumn": 19, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 1, - "endLine": 26, - "endColumn": 20, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 8, - "endLine": 26, - "endColumn": 20, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 12, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 1, - "endLine": 28, - "endColumn": 17, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 17, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 17, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 12, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 11, - "endLine": 30, - "endColumn": 20, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 11, - "endLine": 30, - "endColumn": 20, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 32, - "column": 23, - "endLine": 32, - "endColumn": 35, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 1, - "endLine": 33, - "endColumn": 20, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 8, - "endLine": 33, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 35, - "column": 21, - "endLine": 35, - "endColumn": 33, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 37, - "column": 12, - "endLine": 37, - "endColumn": 28, - "problem": "InteropCallObjectMethods", - "suggest": "", - "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", - "severity": "ERROR" - }, - { - "line": 43, - "column": 10, - "endLine": 43, - "endColumn": 28, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 43, - "column": 24, - "endLine": 43, - "endColumn": 27, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 45, - "column": 3, - "endLine": 45, - "endColumn": 22, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 45, - "column": 10, - "endLine": 45, - "endColumn": 22, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 48, - "column": 21, - "endLine": 48, - "endColumn": 39, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 48, - "column": 35, - "endLine": 48, - "endColumn": 38, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 50, - "column": 7, - "endLine": 50, - "endColumn": 13, - "problem": "InvalidIdentifier", - "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", - "severity": "ERROR" - }, - { - "line": 62, - "column": 5, - "endLine": 62, - "endColumn": 21, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 62, - "column": 12, - "endLine": 62, - "endColumn": 21, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 62, - "column": 12, - "endLine": 62, - "endColumn": 21, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 28, - "endLine": 66, - "endColumn": 47, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 35, - "endLine": 66, - "endColumn": 47, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 70, - "column": 1, - "endLine": 70, - "endColumn": 13, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 1, - "endLine": 71, - "endColumn": 25, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 8, - "endLine": 71, - "endColumn": 25, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 8, - "endLine": 71, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 72, - "column": 1, - "endLine": 72, - "endColumn": 30, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 72, - "column": 8, - "endLine": 72, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 1, - "endLine": 73, - "endColumn": 31, - "problem": "InterOpImportJsForTypeOf", - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 8, - "endLine": 73, - "endColumn": 31, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 8, - "endLine": 73, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 28, - "endLine": 73, - "endColumn": 30, - "problem": "NumericSemantics", - "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": 16, + "column": 1, + "endLine": 16, + "endColumn": 69, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 54, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 55, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 15, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 18, + "problem": "CallJSFunction", + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 11, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 19, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 8, + "endLine": 24, + "endColumn": 19, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 20, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 8, + "endLine": 25, + "endColumn": 20, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 12, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 17, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 17, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 1, + "endLine": 28, + "endColumn": 12, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 20, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 35, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 20, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 8, + "endLine": 32, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 21, + "endLine": 34, + "endColumn": 33, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 22, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 12, + "endLine": 36, + "endColumn": 28, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 10, + "endLine": 42, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 24, + "endLine": 42, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 22, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 10, + "endLine": 44, + "endColumn": 22, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 21, + "endLine": 47, + "endColumn": 39, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 35, + "endLine": 47, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 7, + "endLine": 49, + "endColumn": 13, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 5, + "endLine": 61, + "endColumn": 21, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 12, + "endLine": 61, + "endColumn": 21, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 28, + "endLine": 65, + "endColumn": 47, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 35, + "endLine": 65, + "endColumn": 47, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 13, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 25, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 8, + "endLine": 70, + "endColumn": 25, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 8, + "endLine": 70, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 30, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 8, + "endLine": 71, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 31, + "problem": "InterOpImportJsForTypeOf", + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 8, + "endLine": 72, + "endColumn": 31, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 8, + "endLine": 72, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 28, + "endLine": 72, + "endColumn": 30, + "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/interop/interop_import_typeof_js.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json old mode 100755 new mode 100644 index e913452998228a35b20b4ce06d1df47e221e9368..a080a8877dd435a10899ad762d2ee6ab0862b41b --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json @@ -1,933 +1,861 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 69, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 69, - "problem": "InterOpImportJs", - "autofix": [ - { - "start": 618, - "end": 686, - "replacementText": "", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 69 - }, - { - "start": 795, - "end": 795, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_import_js_js');\nlet myAaa = GeneratedImportVar_1.getPropertyByName('aaa');\nlet ClassA = GeneratedImportVar_1.getPropertyByName('ClassA');\nlet Dog = GeneratedImportVar_1.getPropertyByName('Dog');\nlet Person = GeneratedImportVar_1.getPropertyByName('Person');\nlet Wiki = GeneratedImportVar_1.getPropertyByName('Wiki');\n", - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 69 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 54, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 54, - "problem": "InterOpImportJs", - "autofix": [ - { - "start": 687, - "end": 740, - "replacementText": "", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 54 - }, - { - "start": 795, - "end": 795, - "replacementText": "let GeneratedImportVar_2 = ESValue.load('./interop_import_js_js');\nlet Doge = GeneratedImportVar_2.getPropertyByName('Dog');\n", - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 54 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 55, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 55, - "problem": "InterOpImportJs", - "autofix": [ - { - "start": 741, - "end": 795, - "replacementText": "", - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 55 - }, - { - "start": 795, - "end": 795, - "replacementText": "let GeneratedImportVar_3 = ESValue.load('./interop_import_js_js');\nlet wiki = GeneratedImportVar_3.getPropertyByName('Wiki');\n", - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 55 - } - ], - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 15, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 797, - "end": 811, - "replacementText": "myAaa.invoke().typeOf()", - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 15 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 11, - "endLine": 22, - "endColumn": 18, - "problem": "CallJSFunction", - "autofix": [ - { - "start": 831, - "end": 838, - "replacementText": "myAaa.invoke()", - "line": 22, - "column": 11, - "endLine": 22, - "endColumn": 18 - } - ], - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 1, - "endLine": 24, - "endColumn": 11, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 852, - "end": 862, - "replacementText": "Dog.typeOf()", - "line": 24, - "column": 1, - "endLine": 24, - "endColumn": 11 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 19, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 872, - "end": 890, - "replacementText": "Dog.invoke(ESValue.wrap('doge')).typeOf()", - "line": 25, - "column": 1, - "endLine": 25, - "endColumn": 19 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 8, - "endLine": 25, - "endColumn": 19, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 1, - "endLine": 26, - "endColumn": 20, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 900, - "end": 919, - "replacementText": "Doge.invoke(ESValue.wrap('doge')).typeOf()", - "line": 26, - "column": 1, - "endLine": 26, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 8, - "endLine": 26, - "endColumn": 20, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 12, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 929, - "end": 940, - "replacementText": "Wiki.typeOf()", - "line": 27, - "column": 1, - "endLine": 27, - "endColumn": 12 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 1, - "endLine": 28, - "endColumn": 17, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 949, - "end": 965, - "replacementText": "Wiki.getPropertyByName('name').typeOf()", - "line": 28, - "column": 1, - "endLine": 28, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 17, - "problem": "InteropObjectProperty", - "autofix": [ - { - "start": 956, - "end": 965, - "replacementText": "Wiki.getPropertyByName(\"name\")", - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 17, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "Wiki.getPropertyByName('name').toString()", - "start": 956, - "end": 965, - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 17 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 12, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 974, - "end": 985, - "replacementText": "wiki.typeOf()", - "line": 29, - "column": 1, - "endLine": 29, - "endColumn": 12 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 11, - "endLine": 30, - "endColumn": 20, - "problem": "InteropObjectProperty", - "autofix": [ - { - "start": 1004, - "end": 1013, - "replacementText": "wiki.getPropertyByName(\"name\")", - "line": 30, - "column": 11, - "endLine": 30, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 11, - "endLine": 30, - "endColumn": 20, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "wiki.getPropertyByName('name').toString()", - "start": 1004, - "end": 1013, - "line": 30, - "column": 11, - "endLine": 30, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 32, - "column": 23, - "endLine": 32, - "endColumn": 35, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1048, - "end": 1060, - "replacementText": "ClassA.instantiate()", - "line": 32, - "column": 23, - "endLine": 32, - "endColumn": 35 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 1, - "endLine": 33, - "endColumn": 20, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1061, - "end": 1080, - "replacementText": "ClassA.instantiate().typeOf()", - "line": 33, - "column": 1, - "endLine": 33, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 8, - "endLine": 33, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1068, - "end": 1080, - "replacementText": "ClassA.instantiate()", - "line": 33, - "column": 8, - "endLine": 33, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 35, - "column": 21, - "endLine": 35, - "endColumn": 33, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1124, - "end": 1136, - "replacementText": "Person.instantiate()", - "line": 35, - "column": 21, - "endLine": 35, - "endColumn": 33 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 37, - "column": 12, - "endLine": 37, - "endColumn": 28, - "problem": "InteropCallObjectMethods", - "autofix": [ - { - "start": 1171, - "end": 1187, - "replacementText": "person.invokeMethod(\"getName\")", - "line": 37, - "column": 12, - "endLine": 37, - "endColumn": 28 - } - ], - "suggest": "", - "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", - "severity": "ERROR" - }, - { - "line": 43, - "column": 10, - "endLine": 43, - "endColumn": 28, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 43, - "column": 24, - "endLine": 43, - "endColumn": 27, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1312, - "end": 1315, - "replacementText": "111.0", - "line": 43, - "column": 24, - "endLine": 43, - "endColumn": 27 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 45, - "column": 3, - "endLine": 45, - "endColumn": 22, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1337, - "end": 1356, - "replacementText": "Person.instantiate().typeOf()", - "line": 45, - "column": 3, - "endLine": 45, - "endColumn": 22 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 45, - "column": 10, - "endLine": 45, - "endColumn": 22, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1344, - "end": 1356, - "replacementText": "Person.instantiate()", - "line": 45, - "column": 10, - "endLine": 45, - "endColumn": 22 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 48, - "column": 21, - "endLine": 48, - "endColumn": 39, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 48, - "column": 35, - "endLine": 48, - "endColumn": 38, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1403, - "end": 1406, - "replacementText": "111.0", - "line": 48, - "column": 35, - "endLine": 48, - "endColumn": 38 - } - ], - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 50, - "column": 7, - "endLine": 50, - "endColumn": 13, - "problem": "InvalidIdentifier", - "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", - "severity": "ERROR" - }, - { - "line": 62, - "column": 5, - "endLine": 62, - "endColumn": 21, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1713, - "end": 1729, - "replacementText": "wiki.getPropertyByName('name').typeOf()", - "line": 62, - "column": 5, - "endLine": 62, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 62, - "column": 12, - "endLine": 62, - "endColumn": 21, - "problem": "InteropObjectProperty", - "autofix": [ - { - "start": 1720, - "end": 1729, - "replacementText": "wiki.getPropertyByName(\"name\")", - "line": 62, - "column": 12, - "endLine": 62, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 62, - "column": 12, - "endLine": 62, - "endColumn": 21, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "wiki.getPropertyByName('name').toString()", - "start": 1720, - "end": 1729, - "line": 62, - "column": 12, - "endLine": 62, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 28, - "endLine": 66, - "endColumn": 47, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1818, - "end": 1837, - "replacementText": "ClassA.instantiate().typeOf()", - "line": 66, - "column": 28, - "endLine": 66, - "endColumn": 47 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 66, - "column": 35, - "endLine": 66, - "endColumn": 47, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1825, - "end": 1837, - "replacementText": "ClassA.instantiate()", - "line": 66, - "column": 35, - "endLine": 66, - "endColumn": 47 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 70, - "column": 1, - "endLine": 70, - "endColumn": 13, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1858, - "end": 1870, - "replacementText": "myAaa.typeOf()", - "line": 70, - "column": 1, - "endLine": 70, - "endColumn": 13 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 1, - "endLine": 71, - "endColumn": 25, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1880, - "end": 1904, - "replacementText": "Person.instantiate().getPropertyByName('name').typeOf()", - "line": 71, - "column": 1, - "endLine": 71, - "endColumn": 25 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 8, - "endLine": 71, - "endColumn": 25, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "new Person().getPropertyByName('name').toString()", - "start": 1887, - "end": 1904, - "line": 71, - "column": 8, - "endLine": 71, - "endColumn": 25 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 71, - "column": 8, - "endLine": 71, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1887, - "end": 1899, - "replacementText": "Person.instantiate()", - "line": 71, - "column": 8, - "endLine": 71, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 72, - "column": 1, - "endLine": 72, - "endColumn": 30, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1914, - "end": 1943, - "replacementText": "Person.instantiate().getPropertyByName('getName').invoke().typeOf()", - "line": 72, - "column": 1, - "endLine": 72, - "endColumn": 30 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 72, - "column": 8, - "endLine": 72, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1921, - "end": 1933, - "replacementText": "Person.instantiate()", - "line": 72, - "column": 8, - "endLine": 72, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 1, - "endLine": 73, - "endColumn": 31, - "problem": "InterOpImportJsForTypeOf", - "autofix": [ - { - "start": 1952, - "end": 1982, - "replacementText": "Person.instantiate().getPropertyByName('setAge').invoke(ESValue.wrap(22)).typeOf()", - "line": 73, - "column": 1, - "endLine": 73, - "endColumn": 31 - } - ], - "suggest": "", - "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 8, - "endLine": 73, - "endColumn": 31, - "problem": "LimitedVoidType", - "suggest": "", - "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 8, - "endLine": 73, - "endColumn": 20, - "problem": "InstantiatedJsOjbect", - "autofix": [ - { - "start": 1959, - "end": 1971, - "replacementText": "Person.instantiate()", - "line": 73, - "column": 8, - "endLine": 73, - "endColumn": 20 - } - ], - "suggest": "", - "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", - "severity": "ERROR" - }, - { - "line": 73, - "column": 28, - "endLine": 73, - "endColumn": 30, - "problem": "NumericSemantics", - "autofix": [ - { - "start": 1979, - "end": 1981, - "replacementText": "22.0", - "line": 73, - "column": 28, - "endLine": 73, - "endColumn": 30 - } - ], - "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": 16, + "column": 1, + "endLine": 16, + "endColumn": 69, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 606, + "end": 674, + "replacementText": "", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 69 + }, + { + "start": 783, + "end": 783, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_import_js_js');\nlet myAaa = GeneratedImportVar_1.getPropertyByName('aaa');\nlet ClassA = GeneratedImportVar_1.getPropertyByName('ClassA');\nlet Dog = GeneratedImportVar_1.getPropertyByName('Dog');\nlet Person = GeneratedImportVar_1.getPropertyByName('Person');\nlet Wiki = GeneratedImportVar_1.getPropertyByName('Wiki');\n", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 69 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 54, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 675, + "end": 728, + "replacementText": "", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 54 + }, + { + "start": 783, + "end": 783, + "replacementText": "let GeneratedImportVar_2 = ESValue.load('./interop_import_js_js');\nlet Doge = GeneratedImportVar_2.getPropertyByName('Dog');\n", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 54 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 55, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 729, + "end": 783, + "replacementText": "", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 55 + }, + { + "start": 783, + "end": 783, + "replacementText": "let GeneratedImportVar_3 = ESValue.load('./interop_import_js_js');\nlet wiki = GeneratedImportVar_3.getPropertyByName('Wiki');\n", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 55 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 15, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 785, + "end": 799, + "replacementText": "myAaa.invoke().typeOf()", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 18, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 819, + "end": 826, + "replacementText": "myAaa.invoke()", + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 11, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 840, + "end": 850, + "replacementText": "Dog.typeOf()", + "line": 23, + "column": 1, + "endLine": 23, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 19, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 860, + "end": 878, + "replacementText": "Dog.invoke(ESValue.wrap('doge')).typeOf()", + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 8, + "endLine": 24, + "endColumn": 19, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 20, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 888, + "end": 907, + "replacementText": "Doge.invoke(ESValue.wrap('doge')).typeOf()", + "line": 25, + "column": 1, + "endLine": 25, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 8, + "endLine": 25, + "endColumn": 20, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 12, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 917, + "end": 928, + "replacementText": "Wiki.typeOf()", + "line": 26, + "column": 1, + "endLine": 26, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 17, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 937, + "end": 953, + "replacementText": "Wiki.getPropertyByName('name').typeOf()", + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 17, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 944, + "end": 953, + "replacementText": "Wiki.getPropertyByName(\"name\")", + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 1, + "endLine": 28, + "endColumn": 12, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 962, + "end": 973, + "replacementText": "wiki.typeOf()", + "line": 28, + "column": 1, + "endLine": 28, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 20, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 992, + "end": 1001, + "replacementText": "wiki.getPropertyByName(\"name\")", + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 35, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1036, + "end": 1048, + "replacementText": "ClassA.instantiate()", + "line": 31, + "column": 23, + "endLine": 31, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 20, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1049, + "end": 1068, + "replacementText": "ClassA.instantiate().typeOf()", + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 8, + "endLine": 32, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1056, + "end": 1068, + "replacementText": "ClassA.instantiate()", + "line": 32, + "column": 8, + "endLine": 32, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 21, + "endLine": 34, + "endColumn": 33, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1112, + "end": 1124, + "replacementText": "Person.instantiate()", + "line": 34, + "column": 21, + "endLine": 34, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 22, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1136, + "end": 1147, + "replacementText": "person.getPropertyByName(\"name\")", + "line": 35, + "column": 11, + "endLine": 35, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 12, + "endLine": 36, + "endColumn": 28, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 1159, + "end": 1175, + "replacementText": "person.invokeMethod(\"getName\")", + "line": 36, + "column": 12, + "endLine": 36, + "endColumn": 28 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 10, + "endLine": 42, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 24, + "endLine": 42, + "endColumn": 27, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1300, + "end": 1303, + "replacementText": "111.0", + "line": 42, + "column": 24, + "endLine": 42, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 22, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1325, + "end": 1344, + "replacementText": "Person.instantiate().typeOf()", + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 10, + "endLine": 44, + "endColumn": 22, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1332, + "end": 1344, + "replacementText": "Person.instantiate()", + "line": 44, + "column": 10, + "endLine": 44, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 21, + "endLine": 47, + "endColumn": 39, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 35, + "endLine": 47, + "endColumn": 38, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1391, + "end": 1394, + "replacementText": "111.0", + "line": 47, + "column": 35, + "endLine": 47, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 7, + "endLine": 49, + "endColumn": 13, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 5, + "endLine": 61, + "endColumn": 21, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1701, + "end": 1717, + "replacementText": "wiki.getPropertyByName('name').typeOf()", + "line": 61, + "column": 5, + "endLine": 61, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 12, + "endLine": 61, + "endColumn": 21, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1708, + "end": 1717, + "replacementText": "wiki.getPropertyByName(\"name\")", + "line": 61, + "column": 12, + "endLine": 61, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 28, + "endLine": 65, + "endColumn": 47, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1806, + "end": 1825, + "replacementText": "ClassA.instantiate().typeOf()", + "line": 65, + "column": 28, + "endLine": 65, + "endColumn": 47 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 35, + "endLine": 65, + "endColumn": 47, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1813, + "end": 1825, + "replacementText": "ClassA.instantiate()", + "line": 65, + "column": 35, + "endLine": 65, + "endColumn": 47 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 13, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1846, + "end": 1858, + "replacementText": "myAaa.typeOf()", + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 25, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1868, + "end": 1892, + "replacementText": "Person.instantiate().getPropertyByName('name').typeOf()", + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 8, + "endLine": 70, + "endColumn": 25, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1875, + "end": 1892, + "replacementText": "new Person().getPropertyByName(\"name\")", + "line": 70, + "column": 8, + "endLine": 70, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 8, + "endLine": 70, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1875, + "end": 1887, + "replacementText": "Person.instantiate()", + "line": 70, + "column": 8, + "endLine": 70, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 30, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1902, + "end": 1931, + "replacementText": "Person.instantiate().invokeMethod(\"getName\").typeOf()", + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 8, + "endLine": 71, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1909, + "end": 1921, + "replacementText": "Person.instantiate()", + "line": 71, + "column": 8, + "endLine": 71, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 31, + "problem": "InterOpImportJsForTypeOf", + "autofix": [ + { + "start": 1940, + "end": 1970, + "replacementText": "Person.instantiate().invokeMethod(\"setAge\", ESValue.wrap(22)).typeOf()", + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 31 + } + ], + "suggest": "", + "rule": "The \"typeof\" expression can't be used with interop JS objects (arkts-interop-js2s-typeof-js-type)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 8, + "endLine": 72, + "endColumn": 31, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 8, + "endLine": 72, + "endColumn": 20, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1947, + "end": 1959, + "replacementText": "Person.instantiate()", + "line": 72, + "column": 8, + "endLine": 72, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 28, + "endLine": 72, + "endColumn": 30, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1967, + "end": 1969, + "replacementText": "22.0", + "line": 72, + "column": 28, + "endLine": 72, + "endColumn": 30 + } + ], + "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/interop/interop_import_typeof_js.ets.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.json index b61974a218a0379e953f24d569b9397beafd431a..ca88f857e960b437dcf767c0ac40be998c8f1236 100755 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.json @@ -13,36 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 69, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 54, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 55, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets index c5dde90dd5e0a65915cd87a53c1ba9bfdd491f29..197a8577ce7a248131c910ab0d674dd4d640243e 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.ets @@ -12,8 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -'use static' + let GeneratedImportVar_3 = ESValue.load('./interop_import_js_js'); @@ -43,7 +42,7 @@ const aClass:ClassA = ClassA.instantiate() ClassA.instantiate().typeOf() //error typeof aClass; let person:Person = Person.instantiate(); -let name =person.name +let name =person.getPropertyByName("name") let name2 =person.invokeMethod("getName") function getPersonInfo(){ typeof person; @@ -79,5 +78,5 @@ class Object { myAaa.typeOf(); //error Person.instantiate().getPropertyByName('name').typeOf() //error -Person.instantiate().getPropertyByName('getName').invoke().typeOf() //error -Person.instantiate().getPropertyByName('setAge').invoke(ESValue.wrap(22.0)).typeOf() //error +Person.instantiate().invokeMethod("getName").typeOf() //error +Person.instantiate().invokeMethod("setAge", ESValue.wrap(22.0)).typeOf() //error diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json index 983fb8071ba4854eebeec49606eff3ab4d27a456..f709470eefd49c7d1de7697c2a05ece3775d7779 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.migrate.json @@ -1,168 +1,168 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "result": [ - { - "line": 19, - "column": 5, - "endLine": 19, - "endColumn": 66, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 58, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 5, - "endLine": 21, - "endColumn": 66, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 5, - "endLine": 22, - "endColumn": 57, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 5, - "endLine": 23, - "endColumn": 66, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 5, - "endLine": 24, - "endColumn": 58, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 5, - "endLine": 25, - "endColumn": 62, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 5, - "endLine": 26, - "endColumn": 56, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 5, - "endLine": 27, - "endColumn": 62, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 5, - "endLine": 28, - "endColumn": 58, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 32, - "column": 5, - "endLine": 32, - "endColumn": 25, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 40, - "column": 5, - "endLine": 40, - "endColumn": 41, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 46, - "column": 5, - "endLine": 46, - "endColumn": 22, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 47, - "column": 5, - "endLine": 47, - "endColumn": 42, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - }, - { - "line": 60, - "column": 7, - "endLine": 60, - "endColumn": 13, - "problem": "InvalidIdentifier", - "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", - "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": 18, + "column": 5, + "endLine": 18, + "endColumn": 66, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 66, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 57, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 66, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 62, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 62, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 25, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 5, + "endLine": 39, + "endColumn": 41, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 5, + "endLine": 45, + "endColumn": 43, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 42, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 7, + "endLine": 59, + "endColumn": 13, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets old mode 100755 new mode 100644 index 3f72e3cf20095970eca698f3f6e5f605c259e563..3aa24611b1453b4efbe69a0875f4b5e7194d0deb --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets @@ -12,12 +12,52 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' -import {foo, person} from "./interop_not_have_property_js" +'use static' +import { foo, person, TestHelper, Machine, User, Person, Employee } from "./interop_not_have_property_js" foo.name foo.name = "456" person.age = 23 person.male = [2, 3] -foo.age = 12 \ No newline at end of file +foo.age = 12 +if (foo.name = "456") { print("true") } + +let a = new foo() +a.age = 12 + +let test_helper = new TestHelper("TEST_INSTANTIATE_JS_OBJECT"); +test_helper.test(() => { + let machine = new Machine(); + return machine.name === "machine"; // arkts-interop-js2s-access-js-prop +}, "machine.name === 'machine'"); + +test_helper.test(() => { + let user = new User("Bob"); + return user.id === "Bob"; // arkts-interop-js2s-access-js-prop +}, "user.id === 'Bob'"); + +test_helper.test(() => { +let user = new User(10); +return user.id === 10;// arkts-interop-js2s-access-js-prop +}, "user.id === 10"); + +test_helper.test(() => { + let user = new User(123n); + return user.id === 123n; // arkts-interop-js2s-access-js-prop +}, "user.id === 123n"); + +test_helper.test(() => { + let user = new User(true); + return user.id === true;// arkts-interop-js2s-access-js-prop +}, "user.id === true"); + +test_helper.test(() => { + let machine = new Person("John", 10); + return machine.name === "machine"; // arkts-interop-js2s-access-js-prop +}, "machine.name === 'machine'"); + +test_helper.test(() => { + let employee = new Employee(); + return employee.name === "employee"; // arkts-interop-js2s-access-js-prop +}, "employee.name === 'employee'"); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.arkts2.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.arkts2.json old mode 100755 new mode 100644 index ce2c2d2d380e4a8a2c01955ae168963ec398e48d..18802c22d55cdd07435bcafaf0f27f6cfc11847f --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.arkts2.json @@ -18,7 +18,7 @@ "line": 17, "column": 1, "endLine": 17, - "endColumn": 59, + "endColumn": 106, "problem": "ImportAfterStatement", "suggest": "", "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", @@ -28,7 +28,7 @@ "line": 17, "column": 1, "endLine": 17, - "endColumn": 59, + "endColumn": 106, "problem": "InterOpImportJs", "suggest": "", "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", @@ -44,16 +44,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 20, "column": 1, @@ -64,16 +54,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 21, "column": 1, @@ -84,16 +64,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 11, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 21, "column": 14, @@ -114,16 +84,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 12, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 22, "column": 16, @@ -156,23 +116,393 @@ }, { "line": 23, - "column": 1, + "column": 11, "endLine": 23, - "endColumn": 8, - "problem": "InteropJsObjectUsage", + "endColumn": 13, + "problem": "NumericSemantics", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 23, - "column": 11, - "endLine": 23, + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 21, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, "endColumn": 13, + "problem": "InteropJsObjectConditionJudgment", + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 18, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 11, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 9, + "endLine": 27, + "endColumn": 11, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 29, + "column": 19, + "endLine": 29, + "endColumn": 63, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 1, + "endLine": 33, + "endColumn": 33, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 19, + "endLine": 31, + "endColumn": 32, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 38, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 24, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 1, + "endLine": 38, + "endColumn": 24, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 16, + "endLine": 36, + "endColumn": 31, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 12, + "endLine": 37, + "endColumn": 29, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 12, + "endLine": 37, + "endColumn": 19, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 1, + "endLine": 43, + "endColumn": 21, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 12, + "endLine": 41, + "endColumn": 24, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 21, + "endLine": 41, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 22, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 15, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 20, + "endLine": 42, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 1, + "endLine": 48, + "endColumn": 23, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 16, + "endLine": 46, + "endColumn": 30, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 12, + "endLine": 47, + "endColumn": 28, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 12, + "endLine": 47, + "endColumn": 19, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 1, + "endLine": 53, + "endColumn": 23, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 16, + "endLine": 51, + "endColumn": 30, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 12, + "endLine": 52, + "endColumn": 28, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 12, + "endLine": 52, + "endColumn": 19, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 1, + "endLine": 58, + "endColumn": 33, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 19, + "endLine": 56, + "endColumn": 41, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 38, + "endLine": 56, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 12, + "endLine": 57, + "endColumn": 38, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 12, + "endLine": 57, + "endColumn": 24, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 1, + "endLine": 63, + "endColumn": 35, + "problem": "InteropCallObjectMethods", + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 20, + "endLine": 61, + "endColumn": 34, + "problem": "InstantiatedJsOjbect", + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 12, + "endLine": 62, + "endColumn": 40, + "problem": "InteropEqualityJudgment", + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 12, + "endLine": 62, + "endColumn": 25, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json old mode 100755 new mode 100644 index 0c4beba4af8407234f89cb6c304fa5bf7b5a4016..d66995a3c66e2ece5eb31247a9916ca8ce6bf5c4 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json @@ -18,7 +18,7 @@ "line": 17, "column": 1, "endLine": 17, - "endColumn": 59, + "endColumn": 106, "problem": "ImportAfterStatement", "suggest": "", "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", @@ -28,26 +28,26 @@ "line": 17, "column": 1, "endLine": 17, - "endColumn": 59, + "endColumn": 106, "problem": "InterOpImportJs", "autofix": [ { "start": 618, - "end": 676, + "end": 723, "replacementText": "", "line": 17, "column": 1, "endLine": 17, - "endColumn": 59 + "endColumn": 106 }, { - "start": 676, - "end": 676, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_not_have_property_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\nlet person = GeneratedImportVar_1.getPropertyByName('person');\n", + "start": 723, + "end": 723, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_not_have_property_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\nlet person = GeneratedImportVar_1.getPropertyByName('person');\nlet TestHelper = GeneratedImportVar_1.getPropertyByName('TestHelper');\nlet Machine = GeneratedImportVar_1.getPropertyByName('Machine');\nlet User = GeneratedImportVar_1.getPropertyByName('User');\nlet Person = GeneratedImportVar_1.getPropertyByName('Person');\nlet Employee = GeneratedImportVar_1.getPropertyByName('Employee');\n", "line": 17, "column": 1, "endLine": 17, - "endColumn": 59 + "endColumn": 106 } ], "suggest": "", @@ -62,8 +62,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 678, - "end": 686, + "start": 725, + "end": 733, "replacementText": "foo.getPropertyByName(\"name\")", "line": 19, "column": 1, @@ -75,27 +75,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('name').toString()", - "start": 678, - "end": 686, - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 9 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 20, "column": 1, @@ -104,8 +83,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 687, - "end": 703, + "start": 734, + "end": 750, "replacementText": "foo.setPropertyByName(\"name\", ESValue.wrap(\"456\"))", "line": 20, "column": 1, @@ -117,27 +96,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('name').toString()", - "start": 687, - "end": 695, - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 9 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 21, "column": 1, @@ -146,8 +104,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 704, - "end": 719, + "start": 751, + "end": 766, "replacementText": "person.setPropertyByName(\"age\", ESValue.wrap(23))", "line": 21, "column": 1, @@ -159,27 +117,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 11, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "person.getPropertyByName('age').toNumber()", - "start": 704, - "end": 714, - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 11 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 21, "column": 14, @@ -188,8 +125,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 717, - "end": 719, + "start": 764, + "end": 766, "replacementText": "23.0", "line": 21, "column": 14, @@ -209,8 +146,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 720, - "end": 740, + "start": 767, + "end": 787, "replacementText": "person.setPropertyByName(\"male\", ESValue.wrap([2, 3]))", "line": 22, "column": 1, @@ -222,27 +159,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 12, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "person.getPropertyByName('male')", - "start": 720, - "end": 731, - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 12 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 22, "column": 16, @@ -251,8 +167,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 735, - "end": 736, + "start": 782, + "end": 783, "replacementText": "2.0", "line": 22, "column": 16, @@ -272,8 +188,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 738, - "end": 739, + "start": 785, + "end": 786, "replacementText": "3.0", "line": 22, "column": 19, @@ -293,8 +209,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 741, - "end": 753, + "start": 788, + "end": 800, "replacementText": "foo.setPropertyByName(\"age\", ESValue.wrap(12))", "line": 23, "column": 1, @@ -308,45 +224,811 @@ }, { "line": 23, - "column": 1, + "column": 11, "endLine": 23, - "endColumn": 8, - "problem": "InteropJsObjectUsage", + "endColumn": 13, + "problem": "NumericSemantics", "autofix": [ { - "replacementText": "foo.getPropertyByName('age')", - "start": 741, - "end": 748, + "start": 798, + "end": 800, + "replacementText": "12.0", "line": 23, - "column": 1, + "column": 11, "endLine": 23, - "endColumn": 8 + "endColumn": 13 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 23, - "column": 11, - "endLine": 23, + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 21, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 805, + "end": 821, + "replacementText": "foo.setPropertyByName(\"name\", ESValue.wrap(\"456\"))", + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, "endColumn": 13, + "problem": "InteropJsObjectConditionJudgment", + "autofix": [ + { + "replacementText": "foo.getPropertyByName('name').toString()", + "start": 805, + "end": 813, + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 18, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 850, + "end": 859, + "replacementText": "foo.instantiate()", + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 11, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 860, + "end": 870, + "replacementText": "a.setPropertyByName(\"age\", ESValue.wrap(12))", + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 9, + "endLine": 27, + "endColumn": 11, "problem": "NumericSemantics", "autofix": [ { - "start": 751, - "end": 753, + "start": 868, + "end": 870, "replacementText": "12.0", - "line": 23, - "column": 11, - "endLine": 23, - "endColumn": 13 + "line": 27, + "column": 9, + "endLine": 27, + "endColumn": 11 } ], "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 29, + "column": 19, + "endLine": 29, + "endColumn": 63, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 890, + "end": 934, + "replacementText": "TestHelper.instantiate(ESValue.wrap(\"TEST_INSTANTIATE_JS_OBJECT\"))", + "line": 29, + "column": 19, + "endLine": 29, + "endColumn": 63 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 1, + "endLine": 33, + "endColumn": 33, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 936, + "end": 1102, + "replacementText": "test_helper.invokeMethod(\"test\", ESValue.wrap(() => {\n let machine = new Machine();\n return machine.name === \"machine\"; // arkts-interop-js2s-access-js-prop\n}), ESValue.wrap(\"machine.name === 'machine'\"))", + "line": 30, + "column": 1, + "endLine": 33, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 19, + "endLine": 31, + "endColumn": 32, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 979, + "end": 992, + "replacementText": "Machine.instantiate()", + "line": 31, + "column": 19, + "endLine": 31, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 38, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1005, + "end": 1031, + "replacementText": "machine.name.areStrictlyEqual(\"machine\")", + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 24, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1005, + "end": 1017, + "replacementText": "machine.getPropertyByName(\"name\")", + "line": 32, + "column": 12, + "endLine": 32, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 1, + "endLine": 38, + "endColumn": 24, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 1105, + "end": 1252, + "replacementText": "test_helper.invokeMethod(\"test\", ESValue.wrap(() => {\n let user = new User(\"Bob\");\n return user.id === \"Bob\"; // arkts-interop-js2s-access-js-prop\n}), ESValue.wrap(\"user.id === 'Bob'\"))", + "line": 35, + "column": 1, + "endLine": 38, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 16, + "endLine": 36, + "endColumn": 31, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1145, + "end": 1160, + "replacementText": "User.instantiate(ESValue.wrap(\"Bob\"))", + "line": 36, + "column": 16, + "endLine": 36, + "endColumn": 31 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 12, + "endLine": 37, + "endColumn": 29, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1173, + "end": 1190, + "replacementText": "user.id.areStrictlyEqual(\"Bob\")", + "line": 37, + "column": 12, + "endLine": 37, + "endColumn": 29 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 12, + "endLine": 37, + "endColumn": 19, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1173, + "end": 1180, + "replacementText": "user.getPropertyByName(\"id\")", + "line": 37, + "column": 12, + "endLine": 37, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 1, + "endLine": 43, + "endColumn": 21, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 1255, + "end": 1384, + "replacementText": "test_helper.invokeMethod(\"test\", ESValue.wrap(() => {\nlet user = new User(10);\nreturn user.id === 10;// arkts-interop-js2s-access-js-prop\n}), ESValue.wrap(\"user.id === 10\"))", + "line": 40, + "column": 1, + "endLine": 43, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 12, + "endLine": 41, + "endColumn": 24, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1291, + "end": 1303, + "replacementText": "User.instantiate(ESValue.wrap(10))", + "line": 41, + "column": 12, + "endLine": 41, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 21, + "endLine": 41, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1300, + "end": 1302, + "replacementText": "10.0", + "line": 41, + "column": 21, + "endLine": 41, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 22, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1312, + "end": 1326, + "replacementText": "user.id.areStrictlyEqual(10)", + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 15, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1312, + "end": 1319, + "replacementText": "user.getPropertyByName(\"id\")", + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 20, + "endLine": 42, + "endColumn": 22, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1324, + "end": 1326, + "replacementText": "10.0", + "line": 42, + "column": 20, + "endLine": 42, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 1, + "endLine": 48, + "endColumn": 23, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 1387, + "end": 1531, + "replacementText": "test_helper.invokeMethod(\"test\", ESValue.wrap(() => {\n let user = new User(123n);\n return user.id === 123n; // arkts-interop-js2s-access-js-prop\n}), ESValue.wrap(\"user.id === 123n\"))", + "line": 45, + "column": 1, + "endLine": 48, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 16, + "endLine": 46, + "endColumn": 30, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1427, + "end": 1441, + "replacementText": "User.instantiate(ESValue.wrap(123n))", + "line": 46, + "column": 16, + "endLine": 46, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 12, + "endLine": 47, + "endColumn": 28, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1454, + "end": 1470, + "replacementText": "user.id.areStrictlyEqual(123n)", + "line": 47, + "column": 12, + "endLine": 47, + "endColumn": 28 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 12, + "endLine": 47, + "endColumn": 19, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1454, + "end": 1461, + "replacementText": "user.getPropertyByName(\"id\")", + "line": 47, + "column": 12, + "endLine": 47, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 1, + "endLine": 53, + "endColumn": 23, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 1534, + "end": 1677, + "replacementText": "test_helper.invokeMethod(\"test\", ESValue.wrap(() => {\n let user = new User(true);\n return user.id === true;// arkts-interop-js2s-access-js-prop\n}), ESValue.wrap(\"user.id === true\"))", + "line": 50, + "column": 1, + "endLine": 53, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 16, + "endLine": 51, + "endColumn": 30, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1574, + "end": 1588, + "replacementText": "User.instantiate(ESValue.wrap(true))", + "line": 51, + "column": 16, + "endLine": 51, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 12, + "endLine": 52, + "endColumn": 28, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1601, + "end": 1617, + "replacementText": "user.id.areStrictlyEqual(true)", + "line": 52, + "column": 12, + "endLine": 52, + "endColumn": 28 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 12, + "endLine": 52, + "endColumn": 19, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1601, + "end": 1608, + "replacementText": "user.getPropertyByName(\"id\")", + "line": 52, + "column": 12, + "endLine": 52, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 1, + "endLine": 58, + "endColumn": 33, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 1680, + "end": 1855, + "replacementText": "test_helper.invokeMethod(\"test\", ESValue.wrap(() => {\n let machine = new Person(\"John\", 10);\n return machine.name === \"machine\"; // arkts-interop-js2s-access-js-prop\n}), ESValue.wrap(\"machine.name === 'machine'\"))", + "line": 55, + "column": 1, + "endLine": 58, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 19, + "endLine": 56, + "endColumn": 41, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1723, + "end": 1745, + "replacementText": "Person.instantiate(ESValue.wrap(\"John\"), ESValue.wrap(10))", + "line": 56, + "column": 19, + "endLine": 56, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 38, + "endLine": 56, + "endColumn": 40, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1742, + "end": 1744, + "replacementText": "10.0", + "line": 56, + "column": 38, + "endLine": 56, + "endColumn": 40 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 12, + "endLine": 57, + "endColumn": 38, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1758, + "end": 1784, + "replacementText": "machine.name.areStrictlyEqual(\"machine\")", + "line": 57, + "column": 12, + "endLine": 57, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 12, + "endLine": 57, + "endColumn": 24, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1758, + "end": 1770, + "replacementText": "machine.getPropertyByName(\"name\")", + "line": 57, + "column": 12, + "endLine": 57, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 1, + "endLine": 63, + "endColumn": 35, + "problem": "InteropCallObjectMethods", + "autofix": [ + { + "start": 1858, + "end": 2030, + "replacementText": "test_helper.invokeMethod(\"test\", ESValue.wrap(() => {\n let employee = new Employee();\n return employee.name === \"employee\"; // arkts-interop-js2s-access-js-prop\n}), ESValue.wrap(\"employee.name === 'employee'\"))", + "line": 60, + "column": 1, + "endLine": 63, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Calling methods of JS Object directly in interop is not allowed (arkts-interop-js2s-call-js-method)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 20, + "endLine": 61, + "endColumn": 34, + "problem": "InstantiatedJsOjbect", + "autofix": [ + { + "start": 1902, + "end": 1916, + "replacementText": "Employee.instantiate()", + "line": 61, + "column": 20, + "endLine": 61, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "ArkTS directly instantiated JS objects is not supported (arkts-interop-js2s-create-js-instance)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 12, + "endLine": 62, + "endColumn": 40, + "problem": "InteropEqualityJudgment", + "autofix": [ + { + "start": 1929, + "end": 1957, + "replacementText": "employee.name.areStrictlyEqual(\"employee\")", + "line": 62, + "column": 12, + "endLine": 62, + "endColumn": 40 + } + ], + "suggest": "", + "rule": "\"JS\" objects can't be used directly as operands of the equality operators (arkts-interop-js2s-equality-judgment)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 12, + "endLine": 62, + "endColumn": 25, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1929, + "end": 1942, + "replacementText": "employee.getPropertyByName(\"name\")", + "line": 62, + "column": 12, + "endLine": 62, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.json index 838a0500a51da618680219ad2074df304e1eff66..e96c8ee4d27b5de8fd471382863075ddee071158 100755 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.json @@ -18,11 +18,21 @@ "line": 17, "column": 1, "endLine": 17, - "endColumn": 59, + "endColumn": 106, "problem": "ImportAfterStatement", "suggest": "", "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 18, + "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/interop/interop_not_have_property_arkts2.ets.migrate.ets b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets index 586868511b0fe70e32df6c0f516fd64bba41c9a5..b5185b29e459cd193a63b971d694af9e248ef987 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.ets @@ -12,15 +12,60 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' +'use static' let GeneratedImportVar_1 = ESValue.load('./interop_not_have_property_js'); let foo = GeneratedImportVar_1.getPropertyByName('foo'); let person = GeneratedImportVar_1.getPropertyByName('person'); +let TestHelper = GeneratedImportVar_1.getPropertyByName('TestHelper'); +let Machine = GeneratedImportVar_1.getPropertyByName('Machine'); +let User = GeneratedImportVar_1.getPropertyByName('User'); +let Person = GeneratedImportVar_1.getPropertyByName('Person'); +let Employee = GeneratedImportVar_1.getPropertyByName('Employee'); foo.getPropertyByName("name") foo.setPropertyByName("name", ESValue.wrap("456")) person.setPropertyByName("age", ESValue.wrap(23.0)) person.setPropertyByName("male", ESValue.wrap([2.0, 3.0])) -foo.setPropertyByName("age", ESValue.wrap(12.0)) \ No newline at end of file +foo.setPropertyByName("age", ESValue.wrap(12.0)) +if (foo.setPropertyByName("name", ESValue.wrap("456"))) { print("true") } + +let a = foo.instantiate() +a.setPropertyByName("age", ESValue.wrap(12.0)) + +let test_helper = TestHelper.instantiate(ESValue.wrap("TEST_INSTANTIATE_JS_OBJECT")); +test_helper.invokeMethod("test", ESValue.wrap(() => { + let machine = new Machine(); + return machine.name === "machine"; // arkts-interop-js2s-access-js-prop +}), ESValue.wrap("machine.name === 'machine'")); + +test_helper.invokeMethod("test", ESValue.wrap(() => { + let user = new User("Bob"); + return user.id === "Bob"; // arkts-interop-js2s-access-js-prop +}), ESValue.wrap("user.id === 'Bob'")); + +test_helper.invokeMethod("test", ESValue.wrap(() => { +let user = new User(10.0); +return user.id === 10.0;// arkts-interop-js2s-access-js-prop +}), ESValue.wrap("user.id === 10")); + +test_helper.invokeMethod("test", ESValue.wrap(() => { + let user = new User(123n); + return user.id === 123n; // arkts-interop-js2s-access-js-prop +}), ESValue.wrap("user.id === 123n")); + +test_helper.invokeMethod("test", ESValue.wrap(() => { + let user = new User(true); + return user.id === true;// arkts-interop-js2s-access-js-prop +}), ESValue.wrap("user.id === true")); + +test_helper.invokeMethod("test", ESValue.wrap(() => { + let machine = new Person("John", 10.0); + return machine.name === "machine"; // arkts-interop-js2s-access-js-prop +}), ESValue.wrap("machine.name === 'machine'")); + +test_helper.invokeMethod("test", ESValue.wrap(() => { + let employee = new Employee(); + return employee.name === "employee"; // arkts-interop-js2s-access-js-prop +}), ESValue.wrap("employee.name === 'employee'")); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json index 17bc19346aae749d288ae9fe18ae878cdee8d9ef..540b5557d45cc7365dc242397e5fad526524d7bd 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.migrate.json @@ -43,6 +43,216 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 70, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 64, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 5, + "endLine": 23, + "endColumn": 62, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 66, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 26, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 85, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 9, + "endLine": 39, + "endColumn": 32, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 23, + "endLine": 39, + "endColumn": 30, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 9, + "endLine": 44, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 20, + "endLine": 44, + "endColumn": 24, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 5, + "endLine": 49, + "endColumn": 26, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 16, + "endLine": 49, + "endColumn": 20, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 9, + "endLine": 54, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 20, + "endLine": 54, + "endColumn": 24, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 9, + "endLine": 59, + "endColumn": 30, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 20, + "endLine": 59, + "endColumn": 24, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 9, + "endLine": 64, + "endColumn": 43, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 23, + "endLine": 64, + "endColumn": 29, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 9, + "endLine": 69, + "endColumn": 34, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 24, + "endLine": 69, + "endColumn": 32, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_js.js b/ets2panda/linter/test/interop/interop_not_have_property_js.js index cd3b2ad79c827240efb0dfeb83a5057f3238fb3d..45b2953a2cf654d08f72cf6f2811e3e7892f37d0 100755 --- a/ets2panda/linter/test/interop/interop_not_have_property_js.js +++ b/ets2panda/linter/test/interop/interop_not_have_property_js.js @@ -13,4 +13,61 @@ * limitations under the License. */ export let foo = {name: "123"} -export let person = {age: 12, male: [1, 2, 3]} \ No newline at end of file +export let person = {age: 12, male: [1, 2, 3]} +export class TestHelper { + constructor(testName) { + this.testName = testName; + this.passed = 0; + this.failed = 0; + } + + test(testFunction, description) { + const result = testFunction(); + if (result) { + this.passed++; + console.log(`[PASS] ${this.testName}: ${description}`); + } else { + this.failed++; + console.error(`[FAIL] ${this.testName}: ${description}`); + } + } + + getStats() { + return { + passed: this.passed, + failed: this.failed, + total: this.passed + this.failed + }; + } + + printSummary() { + const stats = this.getStats(); + } +} + +export class Machine { + name = "machine"; +} + +export class User { + id; + constructor(a){ + this.id = a; + } +} + +export class Person { + name; + age; + constructor(a, b){ + this.name = a; + this.age = b; + } +} + +export class Employee { + name; + constructor(a = "employee"){ + this.name = a; + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets old mode 100755 new mode 100644 index 1049aac0f00e701d6e1ad108fcc92ab88dcf7933..8c41ae41820260ad9b446e203c8ebc8c7c096e4e --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' import {foo} from "./interop_property_num_js" diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.arkts2.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.arkts2.json old mode 100755 new mode 100644 index 414d9f77210b68d5546e3d261c39852de9ee43a0..ccb4943134ffca9cc6af97e2bdd741057074e0e4 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, - "endColumn": 46, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 46, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 9, "problem": "InteropNoHaveNum", "suggest": "", @@ -45,23 +35,33 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 2, - "endLine": 19, + "endLine": 18, "endColumn": 9, "problem": "InteropObjectProperty", "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, { "line": 19, "column": 2, "endLine": 19, "endColumn": 9, - "problem": "InteropJsObjectUsage", + "problem": "InteropObjectProperty", "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { @@ -84,16 +84,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 20, - "column": 2, - "endLine": 20, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 21, "column": 1, @@ -114,21 +104,11 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 21, - "column": 2, - "endLine": 21, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 22, "column": 1, "endLine": 22, - "endColumn": 9, + "endColumn": 11, "problem": "InteropNoHaveNum", "suggest": "", "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", @@ -136,24 +116,14 @@ }, { "line": 22, - "column": 2, + "column": 3, "endLine": 22, - "endColumn": 9, + "endColumn": 10, "problem": "InteropObjectProperty", "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 22, - "column": 2, - "endLine": 22, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 23, "column": 1, @@ -174,16 +144,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 23, - "column": 3, - "endLine": 23, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 24, "column": 1, @@ -204,16 +164,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 24, - "column": 3, - "endLine": 24, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 25, "column": 1, @@ -233,46 +183,6 @@ "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" - }, - { - "line": 25, - "column": 3, - "endLine": 25, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 1, - "endLine": 26, - "endColumn": 11, - "problem": "InteropNoHaveNum", - "suggest": "", - "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 3, - "endLine": 26, - "endColumn": 10, - "problem": "InteropObjectProperty", - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 3, - "endLine": 26, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json old mode 100755 new mode 100644 index 4452cefcfd558d981573f96c553799bb22d28897..c638dec23eb3a73a32118f3b47305f1a70ee4777 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json @@ -15,35 +15,29 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, - "endColumn": 46, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 46, "problem": "InterOpImportJs", "autofix": [ { - "start": 618, - "end": 663, + "start": 605, + "end": 650, "replacementText": "", - "line": 17, + "line": 16, "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 46 }, { - "start": 663, - "end": 663, - "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_property_num_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n" + "start": 650, + "end": 650, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./interop_property_num_js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 46 } ], "suggest": "", @@ -51,19 +45,19 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 9, "problem": "InteropNoHaveNum", "autofix": [ { - "start": 666, - "end": 673, + "start": 653, + "end": 660, "replacementText": "foo.getPropertyByName(\"num\").toNumber()", - "line": 19, + "line": 18, "column": 1, - "endLine": 19, + "endLine": 18, "endColumn": 9 } ], @@ -72,19 +66,19 @@ "severity": "ERROR" }, { - "line": 19, + "line": 18, "column": 2, - "endLine": 19, + "endLine": 18, "endColumn": 9, "problem": "InteropObjectProperty", "autofix": [ { - "start": 666, - "end": 673, + "start": 653, + "end": 660, "replacementText": "foo.getPropertyByName(\"num\")", - "line": 19, + "line": 18, "column": 2, - "endLine": 19, + "endLine": 18, "endColumn": 9 } ], @@ -94,65 +88,65 @@ }, { "line": 19, - "column": 2, + "column": 1, "endLine": 19, "endColumn": 9, - "problem": "InteropJsObjectUsage", + "problem": "InteropNoHaveNum", "autofix": [ { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 666, - "end": 673, + "start": 663, + "end": 670, + "replacementText": "foo.getPropertyByName(\"num\").toNumber()", "line": 19, - "column": 2, + "column": 1, "endLine": 19, "endColumn": 9 } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, { - "line": 20, - "column": 1, - "endLine": 20, + "line": 19, + "column": 2, + "endLine": 19, "endColumn": 9, - "problem": "InteropNoHaveNum", + "problem": "InteropObjectProperty", "autofix": [ { - "start": 676, - "end": 683, - "replacementText": "foo.getPropertyByName(\"num\").toNumber()", - "line": 20, - "column": 1, - "endLine": 20, + "start": 663, + "end": 670, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 19, + "column": 2, + "endLine": 19, "endColumn": 9 } ], "suggest": "", - "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { "line": 20, - "column": 2, + "column": 1, "endLine": 20, "endColumn": 9, - "problem": "InteropObjectProperty", + "problem": "InteropNoHaveNum", "autofix": [ { - "start": 676, - "end": 683, - "replacementText": "foo.getPropertyByName(\"num\")", + "start": 673, + "end": 680, + "replacementText": "foo.getPropertyByName(\"num\").toNumber()", "line": 20, - "column": 2, + "column": 1, "endLine": 20, "endColumn": 9 } ], "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, { @@ -160,12 +154,12 @@ "column": 2, "endLine": 20, "endColumn": 9, - "problem": "InteropJsObjectUsage", + "problem": "InteropObjectProperty", "autofix": [ { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 676, - "end": 683, + "start": 673, + "end": 680, + "replacementText": "foo.getPropertyByName(\"num\")", "line": 20, "column": 2, "endLine": 20, @@ -173,7 +167,7 @@ } ], "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, { @@ -184,8 +178,8 @@ "problem": "InteropNoHaveNum", "autofix": [ { - "start": 686, - "end": 693, + "start": 683, + "end": 690, "replacementText": "foo.getPropertyByName(\"num\").toNumber()", "line": 21, "column": 1, @@ -205,8 +199,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 686, - "end": 693, + "start": 683, + "end": 690, "replacementText": "foo.getPropertyByName(\"num\")", "line": 21, "column": 2, @@ -218,42 +212,21 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 21, - "column": 2, - "endLine": 21, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 686, - "end": 693, - "line": 21, - "column": 2, - "endLine": 21, - "endColumn": 9 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 22, "column": 1, "endLine": 22, - "endColumn": 9, + "endColumn": 11, "problem": "InteropNoHaveNum", "autofix": [ { - "start": 696, - "end": 703, - "replacementText": "foo.getPropertyByName(\"num\").toNumber()", + "start": 693, + "end": 702, + "replacementText": "(foo.getPropertyByName(\"num\").toNumber())", "line": 22, "column": 1, "endLine": 22, - "endColumn": 9 + "endColumn": 11 } ], "suggest": "", @@ -262,46 +235,25 @@ }, { "line": 22, - "column": 2, + "column": 3, "endLine": 22, - "endColumn": 9, + "endColumn": 10, "problem": "InteropObjectProperty", "autofix": [ { - "start": 696, - "end": 703, + "start": 694, + "end": 701, "replacementText": "foo.getPropertyByName(\"num\")", "line": 22, - "column": 2, + "column": 3, "endLine": 22, - "endColumn": 9 + "endColumn": 10 } ], "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 22, - "column": 2, - "endLine": 22, - "endColumn": 9, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 696, - "end": 703, - "line": 22, - "column": 2, - "endLine": 22, - "endColumn": 9 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 23, "column": 1, @@ -310,8 +262,8 @@ "problem": "InteropNoHaveNum", "autofix": [ { - "start": 706, - "end": 715, + "start": 705, + "end": 714, "replacementText": "(foo.getPropertyByName(\"num\").toNumber())", "line": 23, "column": 1, @@ -331,8 +283,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 707, - "end": 714, + "start": 706, + "end": 713, "replacementText": "foo.getPropertyByName(\"num\")", "line": 23, "column": 3, @@ -344,27 +296,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 23, - "column": 3, - "endLine": 23, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 707, - "end": 714, - "line": 23, - "column": 3, - "endLine": 23, - "endColumn": 10 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 24, "column": 1, @@ -373,8 +304,8 @@ "problem": "InteropNoHaveNum", "autofix": [ { - "start": 718, - "end": 727, + "start": 717, + "end": 726, "replacementText": "(foo.getPropertyByName(\"num\").toNumber())", "line": 24, "column": 1, @@ -394,8 +325,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 719, - "end": 726, + "start": 718, + "end": 725, "replacementText": "foo.getPropertyByName(\"num\")", "line": 24, "column": 3, @@ -407,27 +338,6 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, - { - "line": 24, - "column": 3, - "endLine": 24, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 719, - "end": 726, - "line": 24, - "column": 3, - "endLine": 24, - "endColumn": 10 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, { "line": 25, "column": 1, @@ -436,8 +346,8 @@ "problem": "InteropNoHaveNum", "autofix": [ { - "start": 730, - "end": 739, + "start": 729, + "end": 738, "replacementText": "(foo.getPropertyByName(\"num\").toNumber())", "line": 25, "column": 1, @@ -457,8 +367,8 @@ "problem": "InteropObjectProperty", "autofix": [ { - "start": 731, - "end": 738, + "start": 730, + "end": 737, "replacementText": "foo.getPropertyByName(\"num\")", "line": 25, "column": 3, @@ -469,90 +379,6 @@ "suggest": "", "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" - }, - { - "line": 25, - "column": 3, - "endLine": 25, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 731, - "end": 738, - "line": 25, - "column": 3, - "endLine": 25, - "endColumn": 10 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 1, - "endLine": 26, - "endColumn": 11, - "problem": "InteropNoHaveNum", - "autofix": [ - { - "start": 742, - "end": 751, - "replacementText": "(foo.getPropertyByName(\"num\").toNumber())", - "line": 26, - "column": 1, - "endLine": 26, - "endColumn": 11 - } - ], - "suggest": "", - "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 3, - "endLine": 26, - "endColumn": 10, - "problem": "InteropObjectProperty", - "autofix": [ - { - "start": 743, - "end": 750, - "replacementText": "foo.getPropertyByName(\"num\")", - "line": 26, - "column": 3, - "endLine": 26, - "endColumn": 10 - } - ], - "suggest": "", - "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 3, - "endLine": 26, - "endColumn": 10, - "problem": "InteropJsObjectUsage", - "autofix": [ - { - "replacementText": "foo.getPropertyByName('num').toNumber()", - "start": 743, - "end": 750, - "line": 26, - "column": 3, - "endLine": 26, - "endColumn": 10 - } - ], - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.json index 456612d680838522a6a4843c38b2df4fa326df96..ca88f857e960b437dcf767c0ac40be998c8f1236 100755 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 46, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets index 1a22e1418c9a3fbf82d7e96e9db282d67d53e8e9..09086d9892f81603449fdd0498a3b3ce220b336c 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' let GeneratedImportVar_1 = ESValue.load('./interop_property_num_js'); let foo = GeneratedImportVar_1.getPropertyByName('foo'); diff --git a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json index 01cf629ed9743d2f465bfce367539feebf811ed4..ef4a1a04e1196434b864ff249bcd12d37a9d92b8 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 5, - "endLine": 17, + "endLine": 16, "endColumn": 69, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 17, "column": 5, - "endLine": 18, + "endLine": 17, "endColumn": 56, "problem": "AnyType", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 21, + "line": 20, "column": 1, - "endLine": 21, + "endLine": 20, "endColumn": 41, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 22, + "line": 21, "column": 1, - "endLine": 22, + "endLine": 21, "endColumn": 41, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 23, "column": 1, - "endLine": 24, + "endLine": 23, "endColumn": 41, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 24, "column": 1, - "endLine": 25, + "endLine": 24, "endColumn": 43, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 25, "column": 1, - "endLine": 26, + "endLine": 25, "endColumn": 43, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 28, + "line": 27, "column": 1, - "endLine": 28, + "endLine": 27, "endColumn": 43, "problem": "UnaryArithmNotNumber", "suggest": "", @@ -95,4 +95,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets b/ets2panda/linter/test/interop/no_await_js_promise.ets old mode 100755 new mode 100644 index 9247c363b44ed65bb043a4311584031f31e6d8fd..124f7b4daba7134bcd6d05ab95a36653ec7cfd43 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets @@ -1,65 +1,64 @@ -/* - * 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. - */ -'use static' - -import { p, foo, pFuncCall, arrowFunc, pArrowCall } from "./no_await_js_promise_export"; - -async function awaitPromise() { - return await p; -} - -async function awaitFunctionCall() { - return await foo(); -} - -async function awaitFuncResult() { - return await pFuncCall; -} - -async function awaitArrowCall() { - return await arrowFunc(); -} - -async function awaitArrowResult() { - return await pArrowCall; -} - -class ExampleClass { - async classMethod() { - return await p; - } - - handler = async () => { - return await pFuncCall; - }; -} - -const exampleObj = { - async objMethod() { - return await pArrowCall; - }, - - arrowHandler: async () => { - return await foo(); - } -}; - -(async function() { - console.log("IIFE result:", await p); -})(); - -(async () => { - console.log("IIFE Arrow result:", await arrowFunc()); +/* + * 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 { p, foo, pFuncCall, arrowFunc, pArrowCall } from "./no_await_js_promise_export"; + +async function awaitPromise() { + return await p; +} + +async function awaitFunctionCall() { + return await foo(); +} + +async function awaitFuncResult() { + return await pFuncCall; +} + +async function awaitArrowCall() { + return await arrowFunc(); +} + +async function awaitArrowResult() { + return await pArrowCall; +} + +class ExampleClass { + async classMethod() { + return await p; + } + + handler = async () => { + return await pFuncCall; + }; +} + +const exampleObj = { + async objMethod() { + return await pArrowCall; + }, + + arrowHandler: async () => { + return await foo(); + } +}; + +(async function() { + console.log("IIFE result:", await p); +})(); + +(async () => { + console.log("IIFE Arrow result:", await arrowFunc()); })(); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.args.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.args.json index 66fb88f85945924e8be0e83d90123507033f4c5d..6958168fef2a70000342107f7d5f2b5805c14fae 100755 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.args.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.args.json @@ -14,6 +14,8 @@ "limitations under the License." ], "mode": { - "arkts2": "" + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" } } diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.arkts2.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.arkts2.json old mode 100755 new mode 100644 index 5021d02c431e482be957465ba47d4f742f95d3f9..13cd6170a9d06c8a69cbf75fe8f5d7207f3d3e86 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.arkts2.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.arkts2.json @@ -1,33 +1,9 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, - "endColumn": 89, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 89, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +11,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 19, "column": 10, - "endLine": 20, + "endLine": 19, "endColumn": 17, "problem": "NoAwaitJsPromise", "suggest": "", @@ -45,9 +21,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 23, "column": 10, - "endLine": 24, + "endLine": 23, "endColumn": 21, "problem": "NoAwaitJsPromise", "suggest": "", @@ -55,19 +31,9 @@ "severity": "ERROR" }, { - "line": 24, - "column": 16, - "endLine": 24, - "endColumn": 21, - "problem": "CallJSFunction", - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 28, + "line": 27, "column": 10, - "endLine": 28, + "endLine": 27, "endColumn": 25, "problem": "NoAwaitJsPromise", "suggest": "", @@ -75,29 +41,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 35, "column": 10, - "endLine": 32, - "endColumn": 27, - "problem": "NoAwaitJsPromise", - "suggest": "", - "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", - "severity": "ERROR" - }, - { - "line": 32, - "column": 16, - "endLine": 32, - "endColumn": 27, - "problem": "CallJSFunction", - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 36, - "column": 10, - "endLine": 36, + "endLine": 35, "endColumn": 26, "problem": "NoAwaitJsPromise", "suggest": "", @@ -105,9 +51,9 @@ "severity": "ERROR" }, { - "line": 41, + "line": 40, "column": 12, - "endLine": 41, + "endLine": 40, "endColumn": 19, "problem": "NoAwaitJsPromise", "suggest": "", @@ -115,9 +61,9 @@ "severity": "ERROR" }, { - "line": 45, + "line": 44, "column": 12, - "endLine": 45, + "endLine": 44, "endColumn": 27, "problem": "NoAwaitJsPromise", "suggest": "", @@ -125,9 +71,9 @@ "severity": "ERROR" }, { - "line": 49, + "line": 48, "column": 20, - "endLine": 49, + "endLine": 48, "endColumn": 21, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -135,9 +81,9 @@ "severity": "ERROR" }, { - "line": 50, + "line": 49, "column": 3, - "endLine": 52, + "endLine": 51, "endColumn": 4, "problem": "ObjectLiteralProperty", "suggest": "", @@ -145,9 +91,9 @@ "severity": "ERROR" }, { - "line": 51, + "line": 50, "column": 12, - "endLine": 51, + "endLine": 50, "endColumn": 28, "problem": "NoAwaitJsPromise", "suggest": "", @@ -155,9 +101,9 @@ "severity": "ERROR" }, { - "line": 55, + "line": 54, "column": 12, - "endLine": 55, + "endLine": 54, "endColumn": 23, "problem": "NoAwaitJsPromise", "suggest": "", @@ -165,19 +111,9 @@ "severity": "ERROR" }, { - "line": 55, - "column": 18, - "endLine": 55, - "endColumn": 23, - "problem": "CallJSFunction", - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" - }, - { - "line": 59, + "line": 58, "column": 2, - "endLine": 61, + "endLine": 60, "endColumn": 2, "problem": "FunctionExpression", "suggest": "", @@ -185,34 +121,14 @@ "severity": "ERROR" }, { - "line": 60, + "line": 59, "column": 31, - "endLine": 60, + "endLine": 59, "endColumn": 38, "problem": "NoAwaitJsPromise", "suggest": "", "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", "severity": "ERROR" - }, - { - "line": 64, - "column": 37, - "endLine": 64, - "endColumn": 54, - "problem": "NoAwaitJsPromise", - "suggest": "", - "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", - "severity": "ERROR" - }, - { - "line": 64, - "column": 43, - "endLine": 64, - "endColumn": 54, - "problem": "CallJSFunction", - "suggest": "", - "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", - "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..5254337c77defbb125385c93025cd3cba914a1f2 --- /dev/null +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.autofix.json @@ -0,0 +1,278 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 89, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 605, + "end": 693, + "replacementText": "", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 89 + }, + { + "start": 693, + "end": 693, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./no_await_js_promise_export');\nlet p = GeneratedImportVar_1.getPropertyByName('p');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\nlet pFuncCall = GeneratedImportVar_1.getPropertyByName('pFuncCall');\nlet arrowFunc = GeneratedImportVar_1.getPropertyByName('arrowFunc');\nlet pArrowCall = GeneratedImportVar_1.getPropertyByName('pArrowCall');\n", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 89 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 10, + "endLine": 19, + "endColumn": 17, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 742, + "end": 743, + "replacementText": "p.toPromise()", + "line": 19, + "column": 10, + "endLine": 19, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 10, + "endLine": 23, + "endColumn": 21, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 800, + "end": 805, + "replacementText": "foo.invoke().toPromise()", + "line": 23, + "column": 10, + "endLine": 23, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 10, + "endLine": 27, + "endColumn": 25, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 860, + "end": 869, + "replacementText": "pFuncCall.toPromise()", + "line": 27, + "column": 10, + "endLine": 27, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 10, + "endLine": 35, + "endColumn": 26, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 990, + "end": 1000, + "replacementText": "pArrowCall.toPromise()", + "line": 35, + "column": 10, + "endLine": 35, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 12, + "endLine": 40, + "endColumn": 19, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 1067, + "end": 1068, + "replacementText": "p.toPromise()", + "line": 40, + "column": 12, + "endLine": 40, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 12, + "endLine": 44, + "endColumn": 27, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 1118, + "end": 1127, + "replacementText": "pFuncCall.toPromise()", + "line": 44, + "column": 12, + "endLine": 44, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 20, + "endLine": 48, + "endColumn": 21, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 3, + "endLine": 51, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 12, + "endLine": 50, + "endColumn": 28, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 1197, + "end": 1207, + "replacementText": "pArrowCall.toPromise()", + "line": 50, + "column": 12, + "endLine": 50, + "endColumn": 28 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 12, + "endLine": 54, + "endColumn": 23, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 1262, + "end": 1267, + "replacementText": "foo.invoke().toPromise()", + "line": 54, + "column": 12, + "endLine": 54, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 2, + "endLine": 60, + "endColumn": 2, + "problem": "FunctionExpression", + "autofix": [ + { + "start": 1278, + "end": 1338, + "replacementText": "async () => {\n console.log(\"IIFE result:\", await p);\n}", + "line": 58, + "column": 2, + "endLine": 60, + "endColumn": 2 + } + ], + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 31, + "endLine": 59, + "endColumn": 38, + "problem": "NoAwaitJsPromise", + "autofix": [ + { + "start": 1333, + "end": 1334, + "replacementText": "p.toPromise()", + "line": 59, + "column": 31, + "endLine": 59, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.json index 5285bc41f634a1abbb69521c2609a6c4aebd006d..02889dfd82b7eb15ba30b481cd8ee682c9a19ea9 100755 --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 89, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 49, + "line": 48, "column": 20, - "endLine": 49, + "endLine": 48, "endColumn": 21, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 59, + "line": 58, "column": 2, - "endLine": 61, + "endLine": 60, "endColumn": 2, "problem": "FunctionExpression", "suggest": "", diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..a89d3e58d376f0943d007c87f0d69510a8f00e0a --- /dev/null +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let GeneratedImportVar_1 = ESValue.load('./no_await_js_promise_export'); +let p = GeneratedImportVar_1.getPropertyByName('p'); +let foo = GeneratedImportVar_1.getPropertyByName('foo'); +let pFuncCall = GeneratedImportVar_1.getPropertyByName('pFuncCall'); +let arrowFunc = GeneratedImportVar_1.getPropertyByName('arrowFunc'); +let pArrowCall = GeneratedImportVar_1.getPropertyByName('pArrowCall'); + + +async function awaitPromise() { + return await p.toPromise(); +} + +async function awaitFunctionCall() { + return await foo.invoke().toPromise(); +} + +async function awaitFuncResult() { + return await pFuncCall.toPromise(); +} + +async function awaitArrowCall() { + return await arrowFunc(); +} + +async function awaitArrowResult() { + return await pArrowCall.toPromise(); +} + +class ExampleClass { + async classMethod() { + return await p.toPromise(); + } + + handler = async () => { + return await pFuncCall.toPromise(); + }; +} + +const exampleObj = { + async objMethod() { + return await pArrowCall.toPromise(); + }, + + arrowHandler: async () => { + return await foo.invoke().toPromise(); + } +}; + +(async () => { + console.log("IIFE result:", await p); +})(); + +(async () => { + console.log("IIFE Arrow result:", await arrowFunc()); +})(); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..5d4c781348cc18bbed693d732d73a9621736bf9e --- /dev/null +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.migrate.json @@ -0,0 +1,188 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 5, + "endLine": 16, + "endColumn": 72, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 68, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 68, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 70, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 16, + "endLine": 24, + "endColumn": 28, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 16, + "endLine": 28, + "endColumn": 33, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 16, + "endLine": 32, + "endColumn": 31, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 16, + "endLine": 36, + "endColumn": 30, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 16, + "endLine": 40, + "endColumn": 32, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 9, + "endLine": 45, + "endColumn": 20, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 13, + "endLine": 51, + "endColumn": 4, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 20, + "endLine": 54, + "endColumn": 21, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 3, + "endLine": 57, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 9, + "endLine": 55, + "endColumn": 18, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 17, + "endLine": 61, + "endColumn": 4, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets b/ets2panda/linter/test/interop/no_js_instanceof.ets old mode 100755 new mode 100644 index f3e57eeee88a4fecf7bfddc410314089fdd77036..9c7c1b645398c89753dbdb8fdf9af53f2f160a57 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' import { Foo, foo, CreatePerson, a , b, MyNamespace } from "./no_js_instanceof_file.js" diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.args.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.args.json index 3ef4496a819a201892114d1c90f78ae32053c334..571ee6bb76b0cad72a9443db47c2f9d7db474bd0 100755 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.args.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.args.json @@ -14,6 +14,8 @@ "limitations under the License." ], "mode": { - "arkts2": "" + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" } } diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.arkts2.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.arkts2.json old mode 100755 new mode 100644 index 31d9a91eefed798e8b18bad28feaf7e89200c341..4c2e0aa32a85010fb6a1740e8c9d192c60057df8 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.arkts2.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, + "line": 16, "column": 1, - "endLine": 17, - "endColumn": 88, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 17, - "column": 1, - "endLine": 17, + "endLine": 16, "endColumn": 88, "problem": "InterOpImportJs", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 4, - "endLine": 27, + "endLine": 26, "endColumn": 22, "problem": "InteropJsInstanceof", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 30, "column": 4, - "endLine": 31, + "endLine": 30, "endColumn": 23, "problem": "InteropJsInstanceof", "suggest": "", @@ -55,9 +45,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 34, "column": 4, - "endLine": 35, + "endLine": 34, "endColumn": 23, "problem": "InteropJsInstanceof", "suggest": "", @@ -65,9 +55,9 @@ "severity": "ERROR" }, { - "line": 39, + "line": 38, "column": 28, - "endLine": 39, + "endLine": 38, "endColumn": 50, "problem": "CallJSFunction", "suggest": "", @@ -75,9 +65,9 @@ "severity": "ERROR" }, { - "line": 39, + "line": 38, "column": 47, - "endLine": 39, + "endLine": 38, "endColumn": 49, "problem": "NumericSemantics", "suggest": "", @@ -85,9 +75,9 @@ "severity": "ERROR" }, { - "line": 41, + "line": 40, "column": 4, - "endLine": 41, + "endLine": 40, "endColumn": 34, "problem": "InteropJsInstanceof", "suggest": "", @@ -95,9 +85,9 @@ "severity": "ERROR" }, { - "line": 46, + "line": 45, "column": 8, - "endLine": 46, + "endLine": 45, "endColumn": 38, "problem": "InteropJsInstanceof", "suggest": "", @@ -105,9 +95,9 @@ "severity": "ERROR" }, { - "line": 52, + "line": 51, "column": 8, - "endLine": 52, + "endLine": 51, "endColumn": 38, "problem": "InteropJsInstanceof", "suggest": "", @@ -115,9 +105,9 @@ "severity": "ERROR" }, { - "line": 59, + "line": 58, "column": 12, - "endLine": 59, + "endLine": 58, "endColumn": 42, "problem": "InteropJsInstanceof", "suggest": "", @@ -125,9 +115,9 @@ "severity": "ERROR" }, { - "line": 65, + "line": 64, "column": 4, - "endLine": 65, + "endLine": 64, "endColumn": 22, "problem": "InteropJsInstanceof", "suggest": "", @@ -135,9 +125,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 68, "column": 4, - "endLine": 69, + "endLine": 68, "endColumn": 24, "problem": "InteropJsInstanceof", "suggest": "", @@ -145,9 +135,9 @@ "severity": "ERROR" }, { - "line": 69, + "line": 68, "column": 4, - "endLine": 69, + "endLine": 68, "endColumn": 7, "problem": "CallJSFunction", "suggest": "", @@ -155,9 +145,9 @@ "severity": "ERROR" }, { - "line": 73, + "line": 72, "column": 36, - "endLine": 73, + "endLine": 72, "endColumn": 51, "problem": "DynamicCtorCall", "suggest": "", @@ -165,9 +155,9 @@ "severity": "ERROR" }, { - "line": 73, + "line": 72, "column": 36, - "endLine": 73, + "endLine": 72, "endColumn": 51, "problem": "InteropObjectProperty", "suggest": "", @@ -175,19 +165,9 @@ "severity": "ERROR" }, { - "line": 73, - "column": 36, - "endLine": 73, - "endColumn": 51, - "problem": "InteropJsObjectUsage", - "suggest": "", - "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js-object-usage)", - "severity": "ERROR" - }, - { - "line": 75, + "line": 74, "column": 5, - "endLine": 75, + "endLine": 74, "endColumn": 37, "problem": "InteropJsInstanceof", "suggest": "", @@ -195,9 +175,9 @@ "severity": "ERROR" }, { - "line": 75, + "line": 74, "column": 22, - "endLine": 75, + "endLine": 74, "endColumn": 37, "problem": "InteropObjectProperty", "suggest": "", @@ -205,9 +185,9 @@ "severity": "ERROR" }, { - "line": 75, + "line": 74, "column": 22, - "endLine": 75, + "endLine": 74, "endColumn": 37, "problem": "InteropJsObjectConditionJudgment", "suggest": "", diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..8b4189586e0b1125edaff37961ec27611be6773f --- /dev/null +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json @@ -0,0 +1,394 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 88, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 605, + "end": 692, + "replacementText": "", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 88 + }, + { + "start": 692, + "end": 692, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./no_js_instanceof_file.js');\nlet Foo = GeneratedImportVar_1.getPropertyByName('Foo');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\nlet CreatePerson = GeneratedImportVar_1.getPropertyByName('CreatePerson');\nlet a = GeneratedImportVar_1.getPropertyByName('a');\nlet b = GeneratedImportVar_1.getPropertyByName('b');\nlet MyNamespace = GeneratedImportVar_1.getPropertyByName('MyNamespace');\n", + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 88 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 4, + "endLine": 26, + "endColumn": 22, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "foo.isInstanceOf(Foo)", + "start": 766, + "end": 784, + "line": 26, + "column": 4, + "endLine": 26, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 4, + "endLine": 30, + "endColumn": 23, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "foo1.isInstanceOf(Foo)", + "start": 799, + "end": 818, + "line": 30, + "column": 4, + "endLine": 30, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 4, + "endLine": 34, + "endColumn": 23, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "foo.isInstanceOf(Foo1)", + "start": 829, + "end": 848, + "line": 34, + "column": 4, + "endLine": 34, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 28, + "endLine": 38, + "endColumn": 50, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 883, + "end": 905, + "replacementText": "CreatePerson.invoke(ESValue.wrap('xc'), ESValue.wrap(18))", + "line": 38, + "column": 28, + "endLine": 38, + "endColumn": 50 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 47, + "endLine": 38, + "endColumn": 49, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 902, + "end": 904, + "replacementText": "18.0", + "line": 38, + "column": 47, + "endLine": 38, + "endColumn": 49 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 4, + "endLine": 40, + "endColumn": 34, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "person.isInstanceOf(CreatePerson)", + "start": 910, + "end": 940, + "line": 40, + "column": 4, + "endLine": 40, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 8, + "endLine": 45, + "endColumn": 38, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "person.isInstanceOf(CreatePerson)", + "start": 980, + "end": 1010, + "line": 45, + "column": 8, + "endLine": 45, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 8, + "endLine": 51, + "endColumn": 38, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "person.isInstanceOf(CreatePerson)", + "start": 1059, + "end": 1089, + "line": 51, + "column": 8, + "endLine": 51, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 12, + "endLine": 58, + "endColumn": 42, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "person.isInstanceOf(CreatePerson)", + "start": 1147, + "end": 1177, + "line": 58, + "column": 12, + "endLine": 58, + "endColumn": 42 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 4, + "endLine": 64, + "endColumn": 22, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "a.isInstanceOf(Array)", + "start": 1204, + "end": 1222, + "line": 64, + "column": 4, + "endLine": 64, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 4, + "endLine": 68, + "endColumn": 24, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "b().isInstanceOf(Array)", + "start": 1233, + "end": 1253, + "line": 68, + "column": 4, + "endLine": 68, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 4, + "endLine": 68, + "endColumn": 7, + "problem": "CallJSFunction", + "autofix": [ + { + "start": 1233, + "end": 1236, + "replacementText": "b.invoke()", + "line": 68, + "column": 4, + "endLine": 68, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "ArkTS directly call JS functions or parameters is not supported (arkts-interop-js2s-call-js-func)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 36, + "endLine": 72, + "endColumn": 51, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 36, + "endLine": 72, + "endColumn": 51, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1296, + "end": 1311, + "replacementText": "MyNamespace.getPropertyByName(\"Dog\")", + "line": 72, + "column": 36, + "endLine": 72, + "endColumn": 51 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 5, + "endLine": 74, + "endColumn": 37, + "problem": "InteropJsInstanceof", + "autofix": [ + { + "replacementText": "myDog.isInstanceOf(MyNamespace.Dog)", + "start": 1327, + "end": 1359, + "line": 74, + "column": 5, + "endLine": 74, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "Usage of \"instanceof\" operator is not allowed with interop objects (arkts-interop-js2s-instanceof-js-type)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 22, + "endLine": 74, + "endColumn": 37, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 1344, + "end": 1359, + "replacementText": "MyNamespace.getPropertyByName(\"Dog\")", + "line": 74, + "column": 22, + "endLine": 74, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 22, + "endLine": 74, + "endColumn": 37, + "problem": "InteropJsObjectConditionJudgment", + "autofix": [ + { + "replacementText": "MyNamespace.getPropertyByName('Dog')", + "start": 1344, + "end": 1359, + "line": 74, + "column": 22, + "endLine": 74, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "Direct usage of interop JS objects is not supported (arkts-interop-js2s-condition-judgment)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.json index e6955adae6bac5e78b91f1b2779d27117f1fde2f..ca88f857e960b437dcf767c0ac40be998c8f1236 100755 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.json @@ -1,29 +1,17 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 88, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..b71a99dcc06a6df1d775598ef974668c47b22515 --- /dev/null +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let GeneratedImportVar_1 = ESValue.load('./no_js_instanceof_file.js'); +let Foo = GeneratedImportVar_1.getPropertyByName('Foo'); +let foo = GeneratedImportVar_1.getPropertyByName('foo'); +let CreatePerson = GeneratedImportVar_1.getPropertyByName('CreatePerson'); +let a = GeneratedImportVar_1.getPropertyByName('a'); +let b = GeneratedImportVar_1.getPropertyByName('b'); +let MyNamespace = GeneratedImportVar_1.getPropertyByName('MyNamespace'); + + +class Foo1 {} + +let foo1 = new Foo1() + +if(foo1 instanceof Foo1) { + +} + +if(foo.isInstanceOf(Foo)) { + +} + +if(foo1.isInstanceOf(Foo)) { + +} + +if(foo.isInstanceOf(Foo1)) { + +} + +let person: CreatePerson = CreatePerson.invoke(ESValue.wrap('xc'), ESValue.wrap(18.0)) + +if(person.isInstanceOf(CreatePerson)) { + +} + +function test1(): void { + if(person.isInstanceOf(CreatePerson)) { + + } +} + +const test2 = (): void => { + if(person.isInstanceOf(CreatePerson)) { + + } +} + +class Test3 { + init(): void { + if(person.isInstanceOf(CreatePerson)) { + + } + } +} + +if(a.isInstanceOf(Array)) { + +} + +if(b().isInstanceOf(Array)) { + +} + +const myDog: MyNamespace.Dog = new MyNamespace.getPropertyByName("Dog")('Buddy'); + +if (myDog.isInstanceOf(MyNamespace.Dog)) { + console.log("This is a Dog!"); +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..63aabda70294bfb97625479c42d6e0484f4acc62 --- /dev/null +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json @@ -0,0 +1,118 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 5, + "endLine": 16, + "endColumn": 70, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 74, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 5, + "endLine": 21, + "endColumn": 52, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 72, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 19, + "endLine": 71, + "endColumn": 24, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 21, + "endLine": 75, + "endColumn": 26, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 36, + "endLine": 79, + "endColumn": 65, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/interop/object_built_in.ets b/ets2panda/linter/test/interop/object_built_in.ets index 7797930ffdc48c71b861f8f690b58f811efd2319..3170f3f087929ed9725c116545ec115437d88e83 100644 --- a/ets2panda/linter/test/interop/object_built_in.ets +++ b/ets2panda/linter/test/interop/object_built_in.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' + import { X } from "./oh_modules/object_built_in" diff --git a/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json b/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json index 07296c65fcf827975765e901537551ce63c21858..d9cadcd5d49e623871668199b128d069f02e845d 100644 --- a/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json +++ b/ets2panda/linter/test/interop/object_built_in.ets.arkts2.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 49, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, { "line": 20, "column": 12, @@ -54,6 +44,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 14, + "problem": "InteropCallObjectParam", + "suggest": "", + "rule": "Class type is not compatible with \"Object\" parameter in interop call (arkts-interop-d2s-static-object-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 27, "column": 1, @@ -65,4 +65,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/object_built_in.ets.json b/ets2panda/linter/test/interop/object_built_in.ets.json index 582a700d940a62a7f8b6fae343ed7bf79d4da05e..d2adea10e51a874fd0c51386e85d2b4552fbecd7 100644 --- a/ets2panda/linter/test/interop/object_built_in.ets.json +++ b/ets2panda/linter/test/interop/object_built_in.ets.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 49, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, { "line": 20, "column": 5, @@ -53,6 +43,16 @@ "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 14, + "problem": "InteropCallObjectParam", + "suggest": "", + "rule": "Class type is not compatible with \"Object\" parameter in interop call (arkts-interop-d2s-static-object-on-dynamic-instance)", + "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/object_literal_constructor.ets b/ets2panda/linter/test/interop/object_literal_constructor.ets index 7c15e1bf64f1cfa040ef5ebaf62e84285eba0321..c66bdfabca6b8b748cc4c5f004e3f5a32b7521ff 100644 --- a/ets2panda/linter/test/interop/object_literal_constructor.ets +++ b/ets2panda/linter/test/interop/object_literal_constructor.ets @@ -1,4 +1,3 @@ -'use static' /* * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/ets2panda/linter/test/interop/object_literal_constructor.ets.arkts2.json b/ets2panda/linter/test/interop/object_literal_constructor.ets.arkts2.json index 6a51dd80b2384cb85784952c10f738f84aaa2cbd..7fe4087dbb650d0fbaf0a53aa3712ff6f2692c8d 100644 --- a/ets2panda/linter/test/interop/object_literal_constructor.ets.arkts2.json +++ b/ets2panda/linter/test/interop/object_literal_constructor.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 101, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 20, + "line": 19, "column": 18, - "endLine": 20, + "endLine": 19, "endColumn": 27, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 19, "column": 24, - "endLine": 20, + "endLine": 19, "endColumn": 25, "problem": "NumericSemantics", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 24, + "line": 23, "column": 22, - "endLine": 24, + "endLine": 23, "endColumn": 51, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -55,9 +45,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 25, "column": 14, - "endLine": 26, + "endLine": 25, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -65,9 +55,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 14, - "endLine": 27, + "endLine": 26, "endColumn": 25, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -75,9 +65,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 16, - "endLine": 27, + "endLine": 26, "endColumn": 23, "problem": "ObjectLiteralProperty", "suggest": "", @@ -85,9 +75,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 16, - "endLine": 27, + "endLine": 26, "endColumn": 23, "problem": "SpreadOperator", "suggest": "", @@ -95,9 +85,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 5, - "endLine": 30, + "endLine": 29, "endColumn": 18, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -105,9 +95,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 35, "column": 12, - "endLine": 36, + "endLine": 35, "endColumn": 29, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -115,9 +105,9 @@ "severity": "ERROR" }, { - "line": 49, + "line": 48, "column": 15, - "endLine": 49, + "endLine": 48, "endColumn": 35, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -125,9 +115,9 @@ "severity": "ERROR" }, { - "line": 57, + "line": 56, "column": 11, - "endLine": 57, + "endLine": 56, "endColumn": 29, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -135,9 +125,9 @@ "severity": "ERROR" }, { - "line": 63, + "line": 62, "column": 30, - "endLine": 63, + "endLine": 62, "endColumn": 48, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -145,9 +135,9 @@ "severity": "ERROR" }, { - "line": 70, + "line": 69, "column": 5, - "endLine": 73, + "endLine": 72, "endColumn": 2, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -155,9 +145,9 @@ "severity": "ERROR" }, { - "line": 72, + "line": 71, "column": 6, - "endLine": 72, + "endLine": 71, "endColumn": 8, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +155,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 78, "column": 5, - "endLine": 79, + "endLine": 78, "endColumn": 24, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -175,9 +165,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 79, "column": 5, - "endLine": 80, + "endLine": 79, "endColumn": 23, "problem": "InteropObjectLiteralClass", "suggest": "", @@ -185,9 +175,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 78, "column": 21, - "endLine": 79, + "endLine": 78, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -195,9 +185,9 @@ "severity": "ERROR" }, { - "line": 80, + "line": 79, "column": 20, - "endLine": 80, + "endLine": 79, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", diff --git a/ets2panda/linter/test/interop/object_literal_constructor.ets.json b/ets2panda/linter/test/interop/object_literal_constructor.ets.json index bafc2e9e5484c606da27a671a0708fcec32cba92..b242a6c5b974b13690bc5e6c8b116ae383f40ff7 100644 --- a/ets2panda/linter/test/interop/object_literal_constructor.ets.json +++ b/ets2panda/linter/test/interop/object_literal_constructor.ets.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 101, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 26, + "line": 25, "column": 14, - "endLine": 26, + "endLine": 25, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 16, - "endLine": 27, + "endLine": 26, "endColumn": 23, "problem": "SpreadOperator", "suggest": "", diff --git a/ets2panda/linter/test/interop/object_literal_union_type.ets b/ets2panda/linter/test/interop/object_literal_union_type.ets index f57fd51379483dadc616f4982de7a53d521c2656..2e730940c353d44edcde943baabc3cbe84d96937 100644 --- a/ets2panda/linter/test/interop/object_literal_union_type.ets +++ b/ets2panda/linter/test/interop/object_literal_union_type.ets @@ -1,4 +1,3 @@ -'use static' /* * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/ets2panda/linter/test/interop/object_literal_union_type.ets.arkts2.json b/ets2panda/linter/test/interop/object_literal_union_type.ets.arkts2.json index 5c02f0cb4d9911bc2709610266b70dc0caf4d404..4b9be812e45c1e79e4d5a1eab9e65a5f8a05af61 100644 --- a/ets2panda/linter/test/interop/object_literal_union_type.ets.arkts2.json +++ b/ets2panda/linter/test/interop/object_literal_union_type.ets.arkts2.json @@ -15,29 +15,19 @@ ], "result": [ { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 63, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 67, - "problem": "ImportAfterStatement", + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 31, + "problem": "InteropObjectLiteralAmbiguity", "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "rule": "Object literal not compatible with target union type. (arkts-interop-d2s-object-literal-no-ambiguity)", "severity": "ERROR" }, { - "line": 21, + "line": 22, "column": 5, - "endLine": 21, + "endLine": 22, "endColumn": 31, "problem": "InteropObjectLiteralAmbiguity", "suggest": "", @@ -45,20 +35,20 @@ "severity": "ERROR" }, { - "line": 23, + "line": 24, "column": 5, - "endLine": 23, - "endColumn": 31, + "endLine": 24, + "endColumn": 37, "problem": "InteropObjectLiteralAmbiguity", "suggest": "", "rule": "Object literal not compatible with target union type. (arkts-interop-d2s-object-literal-no-ambiguity)", "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 5, - "endLine": 25, - "endColumn": 37, + "endLine": 26, + "endColumn": 34, "problem": "InteropObjectLiteralAmbiguity", "suggest": "", "rule": "Object literal not compatible with target union type. (arkts-interop-d2s-object-literal-no-ambiguity)", diff --git a/ets2panda/linter/test/interop/object_literal_union_type.ets.json b/ets2panda/linter/test/interop/object_literal_union_type.ets.json index 25154ac0c6605dd88492da69d54ca7d7a2cda0d5..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/object_literal_union_type.ets.json +++ b/ets2panda/linter/test/interop/object_literal_union_type.ets.json @@ -13,26 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 17, - "column": 1, - "endLine": 17, - "endColumn": 63, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 1, - "endLine": 19, - "endColumn": 67, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/oh_modules/object_literal_union_type_arkts2.ets b/ets2panda/linter/test/interop/oh_modules/object_literal_union_type_arkts2.ets index dad32c88bac85147e6236659ba62ac53ecb691ea..81c8a334d4028ca4afe793d13a1cdae8e730ac59 100644 --- a/ets2panda/linter/test/interop/oh_modules/object_literal_union_type_arkts2.ets +++ b/ets2panda/linter/test/interop/oh_modules/object_literal_union_type_arkts2.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' export class A { name: string = '' } export interface B { name: string, age?: number } diff --git a/ets2panda/linter/test/interop/oh_modules/reflect_export.ets b/ets2panda/linter/test/interop/oh_modules/reflect_export.ets index 4fd2894dd8489f827482c493f3d1782ef57e0d1a..5bfb75a30158144e237625107f8896eed1276e9c 100644 --- a/ets2panda/linter/test/interop/oh_modules/reflect_export.ets +++ b/ets2panda/linter/test/interop/oh_modules/reflect_export.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' export function foo(prx: Object) { Reflect.get(prx, 'a') // 'hello' @@ -28,3 +27,37 @@ export class X { a: string = 'hello' getName() { return this.a } } + +export class Reflect1 { + a: string = 'hello' + getName() { return this.a } +} +export let obj_Reflect1 = new Reflect1(); + +interface Iface { + a:number +} +export let objInter:Iface = {a:1} + +export function reflect_method1(prx: ESObject) { + Reflect.ownKeys(prx) // ['a'] + Reflect.set(prx, 'a', 7) // true + Reflect.get(prx, 'a') // true + Reflect.has(prx, 'a') // true +} + +export function reflect_method1_set(prx: ESObject) { + Reflect.set(prx, 'a', 7) // true +} + +export function reflect_method1_get(prx: ESObject) { + Reflect.get(prx, 'a') // true +} + +export function reflect_method1_ownKeys(prx: ESObject) { + Reflect.ownKeys(prx) // ['a'] +} + +export function reflect_method1_has(prx: ESObject) { + Reflect.has(prx, 'a') // true +} diff --git a/ets2panda/linter/test/interop/oh_modules/static_object_literals_export.ets b/ets2panda/linter/test/interop/oh_modules/static_object_literals_export.ets index 2191e0197101822d16e3f3af4bc71f7162305b9b..540539ec6b9b475b6a7adcff5c4da0e6fb871e43 100644 --- a/ets2panda/linter/test/interop/oh_modules/static_object_literals_export.ets +++ b/ets2panda/linter/test/interop/oh_modules/static_object_literals_export.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' export class X { name: string = '' } diff --git a/ets2panda/linter/test/interop/reflect_built_in.ets b/ets2panda/linter/test/interop/reflect_built_in.ets index 96b0800185e89fcc3bdf12c6ce9ac7dfd106ec0e..90b377fc15ded3c6fd2617cfedbe2c12d2adbc67 100644 --- a/ets2panda/linter/test/interop/reflect_built_in.ets +++ b/ets2panda/linter/test/interop/reflect_built_in.ets @@ -12,8 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' - import { X } from "./oh_modules/reflect_export" export function foo(prx: Object) { @@ -29,3 +27,34 @@ export function bar(obj: Object) { foo(new X()); //illegal bar(new X()); //illegal + +import {Reflect1} from "./oh_modules/reflect_export" +import {obj_Reflect1} from "./oh_modules/reflect_export" +import {objInter} from "./oh_modules/reflect_export" + +function reflect_method2(prx: Object) { + Reflect.get(prx, 'a') // 'hello' + Reflect.set(prx, 'a', 'world') // true + Reflect.ownKeys(prx) // ['a'] +} + +reflect_method2(new Reflect1()); +Reflect.get(new Reflect1(), 'a') +Reflect.set(new Reflect1(), 'a', 'world') +Reflect.ownKeys(new Reflect1()) +let obj = new Reflect1() +reflect_method2(obj); +Reflect.get(obj, 'a') +Reflect.set(obj, 'a', 'world') +Reflect.ownKeys(obj) + +reflect_method2(obj_Reflect1); +Reflect.get(obj_Reflect1, 'a') +Reflect.set(obj_Reflect1, 'a', 'world') +Reflect.ownKeys(obj_Reflect1) + +reflect_method2(objInter); +Reflect.get(objInter, 'a') +Reflect.set(objInter, 'a', 'world') +Reflect.ownKeys(objInter) + diff --git a/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json b/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json index f16e3c2498d6026be25ace4fff06b3a1efb26bde..1dd3014588321927823c43ed04ac101322efcd1e 100644 --- a/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json +++ b/ets2panda/linter/test/interop/reflect_built_in.ets.arkts2.json @@ -15,13 +15,73 @@ ], "result": [ { - "line": 17, + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 23, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 32, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 22, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 37, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 27, "column": 1, - "endLine": 17, - "endColumn": 48, - "problem": "ImportAfterStatement", + "endLine": 27, + "endColumn": 14, + "problem": "InteropCallReflect", "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 1, + "endLine": 27, + "endColumn": 14, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 14, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" }, { @@ -38,11 +98,261 @@ "line": 31, "column": 1, "endLine": 31, - "endColumn": 14, + "endColumn": 53, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 57, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 1, + "endLine": 33, + "endColumn": 53, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 26, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 35, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 25, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 1, + "endLine": 41, + "endColumn": 33, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 1, + "endLine": 41, + "endColumn": 33, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 1, + "endLine": 42, + "endColumn": 33, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 42, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 1, + "endLine": 44, + "endColumn": 32, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 1, + "endLine": 46, + "endColumn": 22, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 1, + "endLine": 46, + "endColumn": 22, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 1, + "endLine": 47, + "endColumn": 22, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 1, + "endLine": 48, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 1, + "endLine": 49, + "endColumn": 21, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 1, + "endLine": 51, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 1, + "endLine": 51, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 1, + "endLine": 52, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 1, + "endLine": 53, + "endColumn": 40, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 1, + "endLine": 54, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 1, + "endLine": 56, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 1, + "endLine": 56, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 1, + "endLine": 57, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 1, + "endLine": 58, + "endColumn": 36, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 1, + "endLine": 59, + "endColumn": 26, "problem": "InteropCallReflect", "suggest": "", "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/reflect_built_in.ets.json b/ets2panda/linter/test/interop/reflect_built_in.ets.json index 0ee87e87fb38c2290a997111c093fa85d4809a32..eb39c3a62eade80d254e29b2184277b8f560519d 100644 --- a/ets2panda/linter/test/interop/reflect_built_in.ets.json +++ b/ets2panda/linter/test/interop/reflect_built_in.ets.json @@ -15,14 +15,284 @@ ], "result": [ { - "line": 17, + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 23, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 32, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 22, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 37, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 27, "column": 1, - "endLine": 17, - "endColumn": 48, + "endLine": 27, + "endColumn": 14, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 1, + "endLine": 29, + "endColumn": 14, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 1, + "endLine": 31, + "endColumn": 53, "problem": "ImportAfterStatement", "suggest": "", "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", "severity": "ERROR" + }, + { + "line": 32, + "column": 1, + "endLine": 32, + "endColumn": 57, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 1, + "endLine": 33, + "endColumn": 53, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 26, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 35, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 25, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 1, + "endLine": 41, + "endColumn": 33, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 1, + "endLine": 42, + "endColumn": 33, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 1, + "endLine": 43, + "endColumn": 42, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 1, + "endLine": 44, + "endColumn": 32, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 1, + "endLine": 46, + "endColumn": 22, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 1, + "endLine": 47, + "endColumn": 22, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 1, + "endLine": 48, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 1, + "endLine": 49, + "endColumn": 21, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 1, + "endLine": 51, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 1, + "endLine": 52, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 1, + "endLine": 53, + "endColumn": 40, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 1, + "endLine": 54, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 1, + "endLine": 56, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 1, + "endLine": 57, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 1, + "endLine": 58, + "endColumn": 36, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 1, + "endLine": 59, + "endColumn": 26, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/static_dynamic_import.ets b/ets2panda/linter/test/interop/static_dynamic_import.ets new file mode 100644 index 0000000000000000000000000000000000000000..7eec28c4196a920c4c209ae4e9daf2ffaea7f188 --- /dev/null +++ b/ets2panda/linter/test/interop/static_dynamic_import.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let arkTsMod = await import('./test_files/dummy_arkts1_file'); +let tsModule = await import('./test_files/dummy_ts_file'); +let jsModule = await import('./test_files/dummy_js_file'); + +function main(): void { + import('./test_files/dummy_ts_file').then((m) => { + console.log(m.Data.name) + }) +} diff --git a/ets2panda/linter/test/interop/static_dynamic_import.ets.arkts2.json b/ets2panda/linter/test/interop/static_dynamic_import.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..dc7f9e0521f966339a23226da90cd2184faf4677 --- /dev/null +++ b/ets2panda/linter/test/interop/static_dynamic_import.ets.arkts2.json @@ -0,0 +1,98 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 16, + "endLine": 16, + "endColumn": 62, + "problem": "InteropDynamicImport", + "suggest": "", + "rule": "No support for static dynamic import (arkts-interop-d2s-dynamic-import)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 22, + "endLine": 16, + "endColumn": 62, + "problem": "DynamicImport", + "suggest": "", + "rule": "Dynamic import is not supported(arkts-no-dynamic-import)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 17, + "endLine": 17, + "endColumn": 59, + "problem": "InteropDynamicImportTs", + "suggest": "", + "rule": "No support for static dynamic import (arkts-interop-ts2s-dynamic-import-ts)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 23, + "endLine": 17, + "endColumn": 59, + "problem": "DynamicImport", + "suggest": "", + "rule": "Dynamic import is not supported(arkts-no-dynamic-import)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 16, + "endLine": 18, + "endColumn": 58, + "problem": "InteropDynamicImportJs", + "suggest": "", + "rule": "No support for static dynamic import (arkts-interop-js2s-dynamic-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 22, + "endLine": 18, + "endColumn": 58, + "problem": "DynamicImport", + "suggest": "", + "rule": "Dynamic import is not supported(arkts-no-dynamic-import)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 3, + "endLine": 21, + "endColumn": 44, + "problem": "InteropDynamicImportTs", + "suggest": "", + "rule": "No support for static dynamic import (arkts-interop-ts2s-dynamic-import-ts)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 3, + "endLine": 21, + "endColumn": 39, + "problem": "DynamicImport", + "suggest": "", + "rule": "Dynamic import is not supported(arkts-no-dynamic-import)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/global_this.ets.migrate.json b/ets2panda/linter/test/interop/static_dynamic_import.ets.json similarity index 67% rename from ets2panda/linter/test/main/global_this.ets.migrate.json rename to ets2panda/linter/test/interop/static_dynamic_import.ets.json index cdc3cef837269d89e24bee549595845bda5cc72b..999000f1d0ecd378bb5189265cc4d871ecc8d227 100644 --- a/ets2panda/linter/test/main/global_this.ets.migrate.json +++ b/ets2panda/linter/test/interop/static_dynamic_import.ets.json @@ -15,43 +15,43 @@ ], "result": [ { - "line": 19, - "column": 7, - "endLine": 19, - "endColumn": 17, - "problem": "GlobalThisError", + "line": 16, + "column": 5, + "endLine": 16, + "endColumn": 62, + "problem": "AnyType", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 24, - "column": 17, - "endLine": 24, - "endColumn": 20, + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 59, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 30, - "column": 7, - "endLine": 30, - "endColumn": 59, + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 58, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 32, - "column": 1, - "endLine": 32, - "endColumn": 7, - "problem": "DeleteOperator", + "line": 21, + "column": 46, + "endLine": 21, + "endColumn": 47, + "problem": "AnyType", "suggest": "", - "rule": "\"delete\" operator is not supported (arkts-no-delete)", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/interop/static_object_literals.ets.json b/ets2panda/linter/test/interop/static_object_literals.ets.json index 12d46c0860e9c1e8e2b8ea429ab13cae1448e3da..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/static_object_literals.ets.json +++ b/ets2panda/linter/test/interop/static_object_literals.ets.json @@ -13,66 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 18, - "column": 12, - "endLine": 18, - "endColumn": 29, - "problem": "InteropStaticObjectLiterals", - "suggest": "", - "rule": "It is not allowed to create object literal in interop calls (arkts-interop-s2d-object-literal)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 12, - "endLine": 22, - "endColumn": 25, - "problem": "InteropStaticObjectLiterals", - "suggest": "", - "rule": "It is not allowed to create object literal in interop calls (arkts-interop-s2d-object-literal)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 5, - "endLine": 26, - "endColumn": 22, - "problem": "InteropStaticObjectLiterals", - "suggest": "", - "rule": "It is not allowed to create object literal in interop calls (arkts-interop-s2d-object-literal)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 5, - "endLine": 30, - "endColumn": 18, - "problem": "InteropStaticObjectLiterals", - "suggest": "", - "rule": "It is not allowed to create object literal in interop calls (arkts-interop-s2d-object-literal)", - "severity": "ERROR" - }, - { - "line": 35, - "column": 12, - "endLine": 35, - "endColumn": 29, - "problem": "InteropStaticObjectLiterals", - "suggest": "", - "rule": "It is not allowed to create object literal in interop calls (arkts-interop-s2d-object-literal)", - "severity": "ERROR" - }, - { - "line": 40, - "column": 17, - "endLine": 40, - "endColumn": 34, - "problem": "InteropStaticObjectLiterals", - "suggest": "", - "rule": "It is not allowed to create object literal in interop calls (arkts-interop-s2d-object-literal)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_name_from_value.ets b/ets2panda/linter/test/interop/unary_operation_js_obj.ets similarity index 80% rename from ets2panda/linter/test/main/prop_name_from_value.ets rename to ets2panda/linter/test/interop/unary_operation_js_obj.ets index bdfdc1a80d5529ad17bdec94f11f1a0e7e493de8..a6d66fee062a7f2ee2f4822230e873f306f7e903 100644 --- a/ets2panda/linter/test/main/prop_name_from_value.ets +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets @@ -12,14 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import {foo} from "./unary_operation_js_obj_js.js" -enum TEST { - A, - B, - C -} -const arr = ['a', 'b', 'c']; - -const val = TEST[1]; -const value: number = TEST.A; //legal -const arrVal = arr[1]; //legal \ No newline at end of file ++foo.num; +-foo.num; +!foo.num; +~foo.num; \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.args.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..a89d885810708ad03d96e3e14bb6590efd1a7547 --- /dev/null +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2024-2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.arkts2.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..13a3e19d15ee7fea3b3f88f509ec22e8b06a9f6c --- /dev/null +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.arkts2.json @@ -0,0 +1,94 @@ +{ + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 51, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 9, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 9, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 9, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 9, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..07cb92eb1a8bc087eb8a4dbbc0cf08eda485a176 --- /dev/null +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json @@ -0,0 +1,216 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 51, + "problem": "InterOpImportJs", + "autofix": [ + { + "start": 604, + "end": 654, + "replacementText": "", + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 51 + }, + { + "start": 654, + "end": 654, + "replacementText": "let GeneratedImportVar_1 = ESValue.load('./unary_operation_js_obj_js.js');\nlet foo = GeneratedImportVar_1.getPropertyByName('foo');\n", + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 51 + } + ], + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "autofix": [ + { + "start": 657, + "end": 664, + "replacementText": "foo.getPropertyByName(\"num\").toNumber()", + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 9, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 657, + "end": 664, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "autofix": [ + { + "start": 667, + "end": 674, + "replacementText": "foo.getPropertyByName(\"num\").toNumber()", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 9, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 667, + "end": 674, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 18, + "column": 2, + "endLine": 18, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "autofix": [ + { + "start": 677, + "end": 684, + "replacementText": "foo.getPropertyByName(\"num\").toNumber()", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 9, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 677, + "end": 684, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 19, + "column": 2, + "endLine": 19, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 9, + "problem": "InteropNoHaveNum", + "autofix": [ + { + "start": 687, + "end": 694, + "replacementText": "foo.getPropertyByName(\"num\").toNumber()", + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 9, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 687, + "end": 694, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..43cb4a27bcc78710d4aa5130c22ee053f66c3fbc --- /dev/null +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.json @@ -0,0 +1,3 @@ +{ + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..5448d6f5f0aab231985e877f6d12ed9a37b69299 --- /dev/null +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +let GeneratedImportVar_1 = ESValue.load('./unary_operation_js_obj_js.js'); +let foo = GeneratedImportVar_1.getPropertyByName('foo'); + + ++foo.getPropertyByName("num").toNumber(); +-foo.getPropertyByName("num").toNumber(); +!foo.getPropertyByName("num").toNumber(); +~foo.getPropertyByName("num").toNumber(); \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..4d448e180c8d4e4bb1569a75f3db5f5f85ffb1c2 --- /dev/null +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.migrate.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 15, + "column": 5, + "endLine": 15, + "endColumn": 74, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 5, + "endLine": 16, + "endColumn": 56, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 41, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 41, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 1, + "endLine": 22, + "endColumn": 41, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unary_operation_js_obj_js.js b/ets2panda/linter/test/interop/unary_operation_js_obj_js.js new file mode 100644 index 0000000000000000000000000000000000000000..6787c967843fb9f771355c300ca676850b9bd3f6 --- /dev/null +++ b/ets2panda/linter/test/interop/unary_operation_js_obj_js.js @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export let foo = {num: 0}; \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types.ets b/ets2panda/linter/test/interop/unique_types.ets index 35f8bae39116bc89fb0ff43ffec5b8c810c399a3..da2c034f53dbd05f0044a1aa2bc0338138269c49 100644 --- a/ets2panda/linter/test/interop/unique_types.ets +++ b/ets2panda/linter/test/interop/unique_types.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' import { objectLiteralType, diff --git a/ets2panda/linter/test/interop/unique_types.ets.arkts2.json b/ets2panda/linter/test/interop/unique_types.ets.arkts2.json index 3c2bcf66a72cc5310f800eb87ad21c0a03a8d0cd..b3274fd8740dd0d83d1c45ea3b2eaab78705489b 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.arkts2.json +++ b/ets2panda/linter/test/interop/unique_types.ets.arkts2.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, + "line": 24, "column": 1, - "endLine": 23, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 1, - "endLine": 25, + "endLine": 24, "endColumn": 23, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 1, - "endLine": 27, + "endLine": 26, "endColumn": 22, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 1, - "endLine": 30, + "endLine": 29, "endColumn": 13, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -55,9 +45,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 1, - "endLine": 30, + "endLine": 29, "endColumn": 11, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -65,19 +55,9 @@ "severity": "ERROR" }, { - "line": 31, - "column": 3, - "endLine": 32, - "endColumn": 2, - "problem": "TsLikeCatchType", - "suggest": "", - "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", - "severity": "ERROR" - }, - { - "line": 34, + "line": 33, "column": 1, - "endLine": 34, + "endLine": 33, "endColumn": 20, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -85,9 +65,9 @@ "severity": "ERROR" }, { - "line": 34, + "line": 33, "column": 1, - "endLine": 34, + "endLine": 33, "endColumn": 11, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -95,4 +75,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types.ets.autofix.json b/ets2panda/linter/test/interop/unique_types.ets.autofix.json index 5f1b6e40b9633eca99cf4f49bf543f25cd3118c7..a6deb3a499e02abb2ae1613ccd00de7a54fe9c5a 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.autofix.json +++ b/ets2panda/linter/test/interop/unique_types.ets.autofix.json @@ -15,29 +15,19 @@ ], "result": [ { - "line": 17, + "line": 24, "column": 1, - "endLine": 23, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 1, - "endLine": 25, + "endLine": 24, "endColumn": 23, "problem": "InteropDirectAccessToTSTypes", "autofix": [ { - "start": 744, - "end": 775, + "start": 731, + "end": 762, "replacementText": "objectLiteralType.setPropertyByName('name',ESValue.wrap(\"test\"))", - "line": 25, + "line": 24, "column": 1, - "endLine": 25, + "endLine": 24, "endColumn": 23 } ], @@ -46,19 +36,19 @@ "severity": "ERROR" }, { - "line": 27, + "line": 26, "column": 1, - "endLine": 27, + "endLine": 26, "endColumn": 22, "problem": "InteropDirectAccessToTSTypes", "autofix": [ { - "start": 777, - "end": 807, + "start": 764, + "end": 794, "replacementText": "intersectionType.setPropertyByName('name',ESValue.wrap(\"test\"))", - "line": 27, + "line": 26, "column": 1, - "endLine": 27, + "endLine": 26, "endColumn": 22 } ], @@ -67,9 +57,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 1, - "endLine": 30, + "endLine": 29, "endColumn": 13, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -77,9 +67,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 1, - "endLine": 30, + "endLine": 29, "endColumn": 11, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -87,19 +77,9 @@ "severity": "ERROR" }, { - "line": 31, - "column": 3, - "endLine": 32, - "endColumn": 2, - "problem": "TsLikeCatchType", - "suggest": "", - "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", - "severity": "ERROR" - }, - { - "line": 34, + "line": 33, "column": 1, - "endLine": 34, + "endLine": 33, "endColumn": 20, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -107,9 +87,9 @@ "severity": "ERROR" }, { - "line": 34, + "line": 33, "column": 1, - "endLine": 34, + "endLine": 33, "endColumn": 11, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -117,4 +97,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types.ets.json b/ets2panda/linter/test/interop/unique_types.ets.json index 3e8e488310b0cc25d757e85c0dad6e55c2c622c1..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.json +++ b/ets2panda/linter/test/interop/unique_types.ets.json @@ -1,14 +1,17 @@ { - "result": [ - { - "line": 17, - "column": 1, - "endLine": 23, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "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": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/interop/unique_types.ets.migrate.ets b/ets2panda/linter/test/interop/unique_types.ets.migrate.ets index 86dd5f4ed051b0282bcfb8c8cfe7d67a1c107233..884003da2478dc331ef9a4f6dde7bcee9fda2c4c 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.migrate.ets +++ b/ets2panda/linter/test/interop/unique_types.ets.migrate.ets @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -'use static' import { objectLiteralType, diff --git a/ets2panda/linter/test/interop/unique_types.ets.migrate.json b/ets2panda/linter/test/interop/unique_types.ets.migrate.json index 4eb8c2c72d3dad88d8e0550785ad1a4a133a9f98..6e0fbe1a85e191bf8014d763561943d0607f7116 100644 --- a/ets2panda/linter/test/interop/unique_types.ets.migrate.json +++ b/ets2panda/linter/test/interop/unique_types.ets.migrate.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 17, + "line": 29, "column": 1, - "endLine": 23, - "endColumn": 38, - "problem": "ImportAfterStatement", - "suggest": "", - "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", - "severity": "ERROR" - }, - { - "line": 30, - "column": 1, - "endLine": 30, + "endLine": 29, "endColumn": 13, "problem": "InteropTSFunctionInvoke", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 30, + "line": 29, "column": 1, - "endLine": 30, + "endLine": 29, "endColumn": 11, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -45,19 +35,9 @@ "severity": "ERROR" }, { - "line": 31, - "column": 3, - "endLine": 32, - "endColumn": 2, - "problem": "TsLikeCatchType", - "suggest": "", - "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", - "severity": "ERROR" - }, - { - "line": 34, + "line": 33, "column": 1, - "endLine": 34, + "endLine": 33, "endColumn": 20, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -65,9 +45,9 @@ "severity": "ERROR" }, { - "line": 34, + "line": 33, "column": 1, - "endLine": 34, + "endLine": 33, "endColumn": 11, "problem": "InteropDirectAccessToTSTypes", "suggest": "", @@ -75,4 +55,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/@ohos.taskpool.ets b/ets2panda/linter/test/main/@ohos.taskpool.ets new file mode 100755 index 0000000000000000000000000000000000000000..eef90ba56a6623ce649296e031f578a85adbab32 --- /dev/null +++ b/ets2panda/linter/test/main/@ohos.taskpool.ets @@ -0,0 +1,36 @@ +/* + * 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 namespace taskpool{ + export function isConcurrent(param:func):boolean { + return true + } + export class Task { + constructor(func: Function, ...args: Object[]){} + setTransferList(transfer?: ArrayBuffer[]): void{} + setCloneList(cloneList: Object[] | ArrayBuffer[]): void{} + } +} +export namespace otherTaskPool{ + export function isConcurrent(param:func):boolean { + return true + } + + export class Task { + constructor(func: Function, ...args: Object[]){} + setTransferList(transfer?: ArrayBuffer[]): void{} + setCloneList(cloneList: Object[] | ArrayBuffer[]): void{} + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/@ohos.taskpool.ets.args.json b/ets2panda/linter/test/main/@ohos.taskpool.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..0adede204e309a92c8aac08d89f6af16d9c93f78 --- /dev/null +++ b/ets2panda/linter/test/main/@ohos.taskpool.ets.args.json @@ -0,0 +1,18 @@ +{ + "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": { + } +} diff --git a/ets2panda/linter/test/main/@ohos.taskpool.ets.json b/ets2panda/linter/test/main/@ohos.taskpool.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..9f305c86d7ff705098b1e480818e125d5e6e3a4a --- /dev/null +++ b/ets2panda/linter/test/main/@ohos.taskpool.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} diff --git a/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.arkts2.json b/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.arkts2.json index b35596cae20fb4d1bd2ba6b07eea07985d574598..0ac07a8af825030b04f70bff8b642f0a022f8458 100644 --- a/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.arkts2.json @@ -91,7 +91,7 @@ "endColumn": 18, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AnimatableExtend\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -151,7 +151,7 @@ "endColumn": 50, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Curve\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -161,7 +161,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.autofix.json b/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.autofix.json index 4a99d7ea8cf975bce36d80b2603d8c7db24f5b04..bedac192c91115faf4abcd5db9227120589c416d 100644 --- a/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.autofix.json +++ b/ets2panda/linter/test/main/animatable_extend_decorator_1.ets.autofix.json @@ -179,7 +179,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AnimatableExtend\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -200,7 +200,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -242,7 +242,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -263,7 +263,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -284,7 +284,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -305,7 +305,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Curve\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -326,7 +326,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/arkts-array-type-immutable.ets b/ets2panda/linter/test/main/arkts-array-type-immutable.ets index 75a02116dd78aca7e564933a329955ca512e8641..c0d79ba0658af6cb3cf6311beede7039474c380f 100644 --- a/ets2panda/linter/test/main/arkts-array-type-immutable.ets +++ b/ets2panda/linter/test/main/arkts-array-type-immutable.ets @@ -34,4 +34,123 @@ let a3: (number | string)[] = new Array(1, 2); // error function test(a: number[]): void { let b: (number | string)[] = [1]; b = a; // error -} \ No newline at end of file +} + +let arrayTypeImmutableA2: [number] = [1]; +let arrayTypeImmutableB2: [number | string] = arrayTypeImmutableA2; + +class ArrayTypeImmutableA{ + arrayTypeImmutableA: number[] = [1]; + arrayTypeImmutableB: (number | string)[] = this.arrayTypeImmutableA; // error + arrayTypeImmutableB1: (number | string)[] = this.arrayTypeImmutableA; // error + + arrayTypeImmutableA2: [number] = [1]; + arrayTypeImmutableB2: [number | string] = arrayTypeImmutableA2; + arrayTypeImmutableB21: [number | string] = this.arrayTypeImmutableA2; +} + +interface IA { + ia: string; +} + +type TA = string | IA + +interface IB { + i: TA|TA[] +} + +class CA { + static fun(...a: IB[]): void{}; +} + +CA.fun({ + i: [ { ia: '1'}, { ia: '2'}, { ia: '3'}, ] as IA[] // error +} as IB) + + +class A { + a: number[] = [-11,0]; + arrayData: (number| string| boolean)[] = [1, 'hi'] + arrs: (number| boolean)[] = new A().a //error + val: (number|string|boolean) [] = new A().arrayData + A() { + const val1 = new A().a + let array2: (string | number | boolean)[] = val1 //error + } + aa(ss:(number| boolean)[]) { + ss = this.a //error + } + cc(): (boolean| number)[] { + return [true, 33]; + } + dd(): (boolean| string| A)[] { + return [true, 'hello', new A()]; + } + ee() { + let ccVal: (boolean | number | boolean)[] = this.cc() + return ccVal; + } + + ff() { + let array: (number| boolean|string)[] = newArr; //error + return array; + } + gg() { + return this.arrs; + } +} + +function test2():(string|number|boolean)[] { + return ['s', 3.14, true]; +} +function test3() { + let obj: A = new A() + return obj.dd(); +} + +let objA: A = new A() + +const newArr: (number| boolean)[] = [1, true] +const newArr1: (number|string|boolean)[] = [1, '3.14', true] +const array: (number | boolean|string)[] = newArr1 +const newArr2: (string|number|boolean)[] = ['s', 3.14, false] +const array1: (number | string | boolean)[] = newArr2 +const array2: (string | number | boolean)[] = newArr1 + +let tt: (boolean | number | boolean)[] = this.test2() //error +let gg: (boolean | number | boolean)[] = new A().ee() +let ff = new A().ff() +let hh: (boolean | number | string)[] =ff +let mm: (boolean | number | boolean)[] = objA.gg(); +let test: (boolean | A | string)[] = test3() + +let array13: (number|boolean|string)[] = newArr as (number|string)[] //error +let array14: (number|boolean|number)[] = [3.14, true] as (number|boolean)[] +let array15: (boolean|number)[] = array as (number|boolean)[] //error +let array16: (boolean | number | boolean)[] = objA.gg() as (boolean | number)[] +let tuple15: (number|boolean|string)[] = this.test2() as (string|number|boolean)[] +let tuple16: (number|boolean)[] = array as [number, number, boolean] +let array17: (number|string|boolean)[] = ['s', 3.14, true] as (number|string|boolean)[] +const array18 = Array.from({ length: 5 }, (_, index) => index % 2 === 0 ? index : index % 3 === 0); +let array19: (number|boolean)[] = array18 as (number)[] //error +const originalArray: number[] = [1, 2, 3, 4, 5]; +const array20 = originalArray.map((value) => value % 2 === 0 ? true : value * 2); +let array21: [number, boolean] = array20 as [number, boolean] +let array22: (number|string)[] = array20 as (number)[] //error +const array23: (number)[] = [1, 2, 3, 4, 5]; + +let aaa: number[] = [1] +let bbb: (number | string)[] = aaa //error +const fn29: Function[] = []; +function bar(): T[] { + return []; +} +let a: number[] = []; +let repairableArr: Array = new Array(); +repairableArr = new Array(3); +Reflect.apply(() => {}, objA, []); +if (handler.apply) handler.apply(objA, objA, []); + +let readonlyArr: ReadonlyArray = []; +let arr66 = new Array(); +readonlyArr = arr66; //error \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json index 50fb25efbd4e185ee01f34994c9860a16d181cac..fa6b50ae6c7b630a3d41a333f3b2360dcc316ab1 100644 --- a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.arkts2.json @@ -123,6 +123,586 @@ "suggest": "", "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", "severity": "ERROR" + }, + { + "line": 39, + "column": 39, + "endLine": 39, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 36, + "endLine": 43, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 3, + "endLine": 44, + "endColumn": 71, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 3, + "endLine": 45, + "endColumn": 72, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 37, + "endLine": 47, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 6, + "endLine": 67, + "endColumn": 63, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 19, + "endLine": 72, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 22, + "endLine": 72, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 45, + "endLine": 73, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 3, + "endLine": 74, + "endColumn": 40, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 9, + "endLine": 78, + "endColumn": 53, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 5, + "endLine": 81, + "endColumn": 16, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 19, + "endLine": 84, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 9, + "endLine": 95, + "endColumn": 51, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 10, + "endLine": 106, + "endColumn": 15, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 38, + "endLine": 113, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 45, + "endLine": 114, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 5, + "endLine": 120, + "endColumn": 54, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 122, + "column": 5, + "endLine": 122, + "endColumn": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 127, + "column": 5, + "endLine": 127, + "endColumn": 69, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 127, + "column": 42, + "endLine": 127, + "endColumn": 69, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 129, + "column": 35, + "endLine": 129, + "endColumn": 62, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 5, + "endLine": 132, + "endColumn": 70, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 36, + "endLine": 132, + "endColumn": 70, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 17, + "endLine": 134, + "endColumn": 99, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 38, + "endLine": 134, + "endColumn": 39, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 44, + "endLine": 134, + "endColumn": 45, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 65, + "endLine": 134, + "endColumn": 66, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 71, + "endLine": 134, + "endColumn": 72, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 91, + "endLine": 134, + "endColumn": 92, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 97, + "endLine": 134, + "endColumn": 98, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 5, + "endLine": 135, + "endColumn": 56, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 35, + "endLine": 135, + "endColumn": 56, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 34, + "endLine": 136, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 37, + "endLine": 136, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 40, + "endLine": 136, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 43, + "endLine": 136, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 46, + "endLine": 136, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 137, + "column": 54, + "endLine": 137, + "endColumn": 55, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 137, + "column": 60, + "endLine": 137, + "endColumn": 61, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 137, + "column": 79, + "endLine": 137, + "endColumn": 80, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 34, + "endLine": 138, + "endColumn": 62, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 5, + "endLine": 139, + "endColumn": 55, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 34, + "endLine": 139, + "endColumn": 55, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 30, + "endLine": 140, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 33, + "endLine": 140, + "endColumn": 34, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 36, + "endLine": 140, + "endColumn": 37, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 39, + "endLine": 140, + "endColumn": 40, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 42, + "endLine": 140, + "endColumn": 43, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 22, + "endLine": 142, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 143, + "column": 5, + "endLine": 143, + "endColumn": 35, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 36, + "endLine": 149, + "endColumn": 47, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 17, + "endLine": 150, + "endColumn": 29, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 27, + "endLine": 150, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 151, + "column": 1, + "endLine": 151, + "endColumn": 54, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 151, + "column": 9, + "endLine": 151, + "endColumn": 14, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 155, + "column": 5, + "endLine": 155, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 156, + "column": 1, + "endLine": 156, + "endColumn": 20, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.json b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.json index ca88f857e960b437dcf767c0ac40be998c8f1236..d8f6775c620327300157f3944a39ef32a7656cc6 100644 --- a/ets2panda/linter/test/main/arkts-array-type-immutable.ets.json +++ b/ets2panda/linter/test/main/arkts-array-type-immutable.ets.json @@ -13,5 +13,66 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 106, + "column": 10, + "endLine": 106, + "endColumn": 15, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 122, + "column": 5, + "endLine": 122, + "endColumn": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 17, + "endLine": 134, + "endColumn": 99, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 44, + "endLine": 134, + "endColumn": 45, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 151, + "column": 1, + "endLine": 151, + "endColumn": 53, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 151, + "column": 1, + "endLine": 151, + "endColumn": 54, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/arktsutils_module.ets b/ets2panda/linter/test/main/arktsutils_module.ets index 4e81dea82b9caa9f42f8000a32557894ad38463d..a8fbe4b65e5e0ecc29045471c29da4584632c4af 100644 --- a/ets2panda/linter/test/main/arktsutils_module.ets +++ b/ets2panda/linter/test/main/arktsutils_module.ets @@ -35,4 +35,6 @@ function tesCollectionsUsage() { type CreatedType = ArkTSUtils.ASON.SomeType; const someType: CreatedType = ArkTSUtils.ASON.SomeType; + + const map: number = ArkTSUtils.ASON.ParseReturnType.map; } diff --git a/ets2panda/linter/test/main/arktsutils_module.ets.arkts2.json b/ets2panda/linter/test/main/arktsutils_module.ets.arkts2.json index 6da6e6ae1588b4a7791270d2b02b227b7b9cf6eb..30c0ecdc72049b06d77ad84ec14d418e9c70e2a9 100644 --- a/ets2panda/linter/test/main/arktsutils_module.ets.arkts2.json +++ b/ets2panda/linter/test/main/arktsutils_module.ets.arkts2.json @@ -113,6 +113,16 @@ "suggest": "", "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", "severity": "ERROR" + }, + { + "line": 39, + "column": 23, + "endLine": 39, + "endColumn": 33, + "problem": "LimitedStdLibNoASON", + "suggest": "", + "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/arktsutils_module.ets.autofix.json b/ets2panda/linter/test/main/arktsutils_module.ets.autofix.json index d6868a9cbf4f513be46a17011c04913690564267..bb4f5f6610bee78fe73dbd965ea29822ece7213e 100644 --- a/ets2panda/linter/test/main/arktsutils_module.ets.autofix.json +++ b/ets2panda/linter/test/main/arktsutils_module.ets.autofix.json @@ -20,6 +20,17 @@ "endLine": 27, "endColumn": 31, "problem": "LimitedStdLibNoASON", + "autofix": [ + { + "start": 980, + "end": 990, + "replacementText": "JSON", + "line": 27, + "column": 26, + "endLine": 27, + "endColumn": 31 + } + ], "suggest": "", "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", "severity": "ERROR" @@ -51,6 +62,17 @@ "endLine": 29, "endColumn": 33, "problem": "LimitedStdLibNoASON", + "autofix": [ + { + "start": 1023, + "end": 1043, + "replacementText": "JSON", + "line": 29, + "column": 18, + "endLine": 29, + "endColumn": 33 + } + ], "suggest": "", "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", "severity": "ERROR" @@ -82,6 +104,17 @@ "endLine": 31, "endColumn": 31, "problem": "LimitedStdLibNoASON", + "autofix": [ + { + "start": 1076, + "end": 1094, + "replacementText": "JSON", + "line": 31, + "column": 18, + "endLine": 31, + "endColumn": 31 + } + ], "suggest": "", "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", "severity": "ERROR" @@ -113,6 +146,17 @@ "endLine": 33, "endColumn": 41, "problem": "LimitedStdLibNoASON", + "autofix": [ + { + "start": 1135, + "end": 1155, + "replacementText": "JSON", + "line": 33, + "column": 26, + "endLine": 33, + "endColumn": 41 + } + ], "suggest": "", "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", "severity": "ERROR" @@ -157,6 +201,16 @@ "suggest": "", "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", "severity": "ERROR" + }, + { + "line": 39, + "column": 23, + "endLine": 39, + "endColumn": 33, + "problem": "LimitedStdLibNoASON", + "suggest": "", + "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/arktsutils_module.ets.migrate.ets b/ets2panda/linter/test/main/arktsutils_module.ets.migrate.ets index 3b1d7e17b6e5f116f3051c61fe671e0dee13327e..5dc1d2c5c20b4c35d42c78d51ede0c60612106fd 100644 --- a/ets2panda/linter/test/main/arktsutils_module.ets.migrate.ets +++ b/ets2panda/linter/test/main/arktsutils_module.ets.migrate.ets @@ -24,15 +24,17 @@ export { utils } from './oh_modules/@arkts.utils'; function tesCollectionsUsage() { - const utils1: string = utils.ASON.stringify(1.0); + const utils1: string = JSON.stringify(1.0); - const utils2 = ArkTSUtilsAlias.ASON.stringify(1.0); + const utils2 = JSON.stringify(1.0); - const utils3 = kitArkTSUtils.ASON.stringify(1.0); + const utils3 = JSON.stringify(1.0); - const utils4: string = ArkTSUtilsAlias.ASON.stringify(1.0); + const utils4: string = JSON.stringify(1.0); type CreatedType = ArkTSUtils.ASON.SomeType; const someType: CreatedType = ArkTSUtils.ASON.SomeType; + + const map: number = ArkTSUtils.ASON.ParseReturnType.map; } diff --git a/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json b/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json index 1b597eff5b8579d13d203bafc99002f5f4b2ce85..a3e735670a47e1abef69d029c41ae952cb0394ec 100644 --- a/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json +++ b/ets2panda/linter/test/main/arktsutils_module.ets.migrate.json @@ -14,46 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 27, - "column": 26, - "endLine": 27, - "endColumn": 31, - "problem": "LimitedStdLibNoASON", - "suggest": "", - "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 18, - "endLine": 29, - "endColumn": 33, - "problem": "LimitedStdLibNoASON", - "suggest": "", - "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", - "severity": "ERROR" - }, - { - "line": 31, - "column": 18, - "endLine": 31, - "endColumn": 31, - "problem": "LimitedStdLibNoASON", - "suggest": "", - "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", - "severity": "ERROR" - }, - { - "line": 33, - "column": 26, - "endLine": 33, - "endColumn": 41, - "problem": "LimitedStdLibNoASON", - "suggest": "", - "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", - "severity": "ERROR" - }, { "line": 35, "column": 22, @@ -73,6 +33,16 @@ "suggest": "", "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", "severity": "ERROR" + }, + { + "line": 39, + "column": 23, + "endLine": 39, + "endColumn": 33, + "problem": "LimitedStdLibNoASON", + "suggest": "", + "rule": "ASON is not supported. (arkts-no-need-stdlib-ason)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets b/ets2panda/linter/test/main/array_index_expr_type.ets index fe370c16cdb5ee0ec55a04f685b25b665d6c4bb1..a2120f59eadc97cba66aeea25367a218c7845f3e 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets +++ b/ets2panda/linter/test/main/array_index_expr_type.ets @@ -83,3 +83,7 @@ arr[a] = 1; arr[b] = 1; arr[c] = 1; arr[d] = 1; + +let test = 1; +arr[1 as number]; +arr[test as number]; \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json b/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json index 40493eb17563e97e8f44bded1361261fa9b00f25..27fa37360de59234f93846778664c5302d071136 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.arkts2.json @@ -1,18 +1,18 @@ { - "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." - ], + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], "result": [ { "line": 17, @@ -64,6 +64,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 18, + "column": 11, + "endLine": 18, + "endColumn": 26, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 18, "column": 20, @@ -84,6 +94,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 19, + "column": 12, + "endLine": 19, + "endColumn": 31, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 19, "column": 21, @@ -104,6 +124,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 20, + "column": 12, + "endLine": 20, + "endColumn": 33, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 20, "column": 21, @@ -124,6 +154,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 21, "column": 20, @@ -244,6 +284,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 27, + "column": 11, + "endLine": 27, + "endColumn": 24, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 27, "column": 20, @@ -264,6 +314,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 28, "column": 20, @@ -284,6 +344,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 22, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 30, "column": 7, @@ -294,6 +364,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 30, + "column": 11, + "endLine": 30, + "endColumn": 37, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 30, "column": 20, @@ -314,6 +394,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 37, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 31, "column": 20, @@ -334,6 +424,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 32, + "column": 11, + "endLine": 32, + "endColumn": 44, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 32, "column": 20, @@ -394,6 +494,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 39, + "column": 1, + "endLine": 39, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 39, "column": 7, @@ -404,6 +514,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 40, + "column": 1, + "endLine": 40, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 40, "column": 7, @@ -414,6 +534,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 41, + "column": 1, + "endLine": 41, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 41, "column": 7, @@ -434,6 +564,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 45, + "column": 1, + "endLine": 45, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 45, "column": 7, @@ -494,6 +634,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 51, + "column": 1, + "endLine": 51, + "endColumn": 19, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 51, "column": 8, @@ -614,6 +764,26 @@ "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)", "severity": "ERROR" }, + { + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 1, + "endLine": 67, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 67, "column": 6, @@ -624,6 +794,46 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 72, "column": 1, @@ -634,11 +844,31 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 1, + "endLine": 73, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 73, "column": 6, "endLine": 73, - "endColumn": 9, + "endColumn": 19, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -714,6 +944,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 18, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 81, "column": 5, @@ -763,6 +1003,66 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 87, + "column": 5, + "endLine": 87, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 12, + "endLine": 87, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 88, + "endColumn": 17, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 5, + "endLine": 88, + "endColumn": 16, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 1, + "endLine": 89, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 5, + "endLine": 89, + "endColumn": 19, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json index ec4168139c9bca5ac69a6316b4577582c358b1b6..a65d5f7162d0ccc39f79bdecb6b1cea66dc75252 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json @@ -1,18 +1,18 @@ { - "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." - ], + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], "result": [ { "line": 17, @@ -119,6 +119,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 18, + "column": 11, + "endLine": 18, + "endColumn": 26, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 18, "column": 20, @@ -161,6 +171,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 19, + "column": 12, + "endLine": 19, + "endColumn": 31, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 19, "column": 21, @@ -203,6 +223,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 20, + "column": 12, + "endLine": 20, + "endColumn": 33, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 20, "column": 21, @@ -245,6 +275,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 21, + "column": 11, + "endLine": 21, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 21, "column": 20, @@ -398,6 +438,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 27, + "column": 11, + "endLine": 27, + "endColumn": 24, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 27, "column": 20, @@ -440,6 +490,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 28, + "column": 11, + "endLine": 28, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 28, "column": 20, @@ -482,6 +542,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 22, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 30, "column": 7, @@ -503,6 +573,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 30, + "column": 11, + "endLine": 30, + "endColumn": 37, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 30, "column": 20, @@ -545,6 +625,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 37, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 31, "column": 20, @@ -587,6 +677,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 32, + "column": 11, + "endLine": 32, + "endColumn": 44, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 32, "column": 20, @@ -713,6 +813,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 39, + "column": 1, + "endLine": 39, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 39, "column": 7, @@ -734,6 +844,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 40, + "column": 1, + "endLine": 40, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 40, "column": 7, @@ -755,6 +875,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 41, + "column": 1, + "endLine": 41, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 41, "column": 7, @@ -797,6 +927,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 45, + "column": 1, + "endLine": 45, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 45, "column": 7, @@ -923,6 +1063,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 51, + "column": 1, + "endLine": 51, + "endColumn": 19, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 51, "column": 8, @@ -1164,6 +1314,37 @@ "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)", "severity": "ERROR" }, + { + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 9, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1669, + "end": 1670, + "replacementText": "0.0", + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 1, + "endLine": 67, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 67, "column": 6, @@ -1185,6 +1366,46 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 72, "column": 1, @@ -1195,11 +1416,31 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 1, + "endLine": 73, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 73, "column": 6, "endLine": 73, - "endColumn": 9, + "endColumn": 19, "problem": "ArrayIndexExprType", "autofix": [ { @@ -1209,7 +1450,7 @@ "line": 73, "column": 6, "endLine": 73, - "endColumn": 9 + "endColumn": 19 } ], "suggest": "", @@ -1363,6 +1604,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 18, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 81, "column": 5, @@ -1456,6 +1707,110 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 87, + "column": 5, + "endLine": 87, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1924, + "end": 1932, + "replacementText": "test: number = 1", + "line": 87, + "column": 5, + "endLine": 87, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 87, + "column": 12, + "endLine": 87, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1931, + "end": 1932, + "replacementText": "1.0", + "line": 87, + "column": 12, + "endLine": 87, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 88, + "endColumn": 17, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 5, + "endLine": 88, + "endColumn": 16, + "problem": "ArrayIndexExprType", + "autofix": [ + { + "start": 1938, + "end": 1949, + "replacementText": "1 as int", + "line": 88, + "column": 5, + "endLine": 88, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 1, + "endLine": 89, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 5, + "endLine": 89, + "endColumn": 19, + "problem": "ArrayIndexExprType", + "autofix": [ + { + "start": 1956, + "end": 1970, + "replacementText": "test as int", + "line": 89, + "column": 5, + "endLine": 89, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets index 5ba7613e1bb2ecbe420289a8147ba00b8740e6ad..eb9ab9c696b2c5a13984cc2a5e64d83fb6de1b13 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets @@ -62,7 +62,7 @@ for (let i: int = 0.0; i < array2.length; i++) { let arr1:number[] = [1.0, 2.0, 3.0] enum TE{ AA = 1.12 - BB = 0 + BB = 0.0 } arr1[TE.AA as int]; arr1[TE.BB]; @@ -83,3 +83,7 @@ arr[a] = 1.0; arr[b] = 1.0; arr[c] = 1.0; arr[d] = 1.0; + +let test: number = 1.0; +arr[1 as int]; +arr[test as int]; \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.json b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.json index 8407a76e0f1a39a6b7313c0ba4b4143b441bb8ad..457bd6501c90d0816d5491b4ff4f56711124a894 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.json +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.json @@ -104,6 +104,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 29, + "column": 19, + "endLine": 29, + "endColumn": 30, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 64, "column": 3, @@ -114,6 +124,46 @@ "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)", "severity": "ERROR" }, + { + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 72, "column": 1, @@ -124,6 +174,26 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 18, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 81, "column": 5, diff --git a/ets2panda/linter/test/main/class_as_object.ets b/ets2panda/linter/test/main/class_as_object.ets index fcc5a362509dbc1bff8eeb8cb5d96f8848fc914e..a2bdc36a95399be407c6029f374cfaac2c55d802 100644 --- a/ets2panda/linter/test/main/class_as_object.ets +++ b/ets2panda/linter/test/main/class_as_object.ets @@ -203,4 +203,13 @@ function parse(type: "number" | "boolean", value: string): number | boolean { } function format(input: string | number): string[] | number[] { return typeof input === "string" ? input.split("") : input.toString().split("").map(Number); -} \ No newline at end of file +} + +let version: string = "1.2" +let a1 = version.split('.').map(Number); + +let version2: string = "1.2" +let a2 = version2.split('.').map(String); + +let version3: string = "1.2" +let a3 = version3.split('.').map(Boolean); \ No newline at end of file diff --git a/ets2panda/linter/test/main/class_as_object.ets.arkts2.json b/ets2panda/linter/test/main/class_as_object.ets.arkts2.json index 3bf41adaebabc702af23e7f93af0ad0ce71cc015..461137accaf6240bf2fdf90a6d49561d3c968c57 100644 --- a/ets2panda/linter/test/main/class_as_object.ets.arkts2.json +++ b/ets2panda/linter/test/main/class_as_object.ets.arkts2.json @@ -334,6 +334,26 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 102, + "column": 13, + "endLine": 102, + "endColumn": 23, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 18, + "endLine": 114, + "endColumn": 25, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 116, "column": 10, @@ -394,36 +414,6 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, - { - "line": 129, - "column": 15, - "endLine": 129, - "endColumn": 21, - "problem": "ClassAsObjectError", - "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", - "severity": "ERROR" - }, - { - "line": 130, - "column": 15, - "endLine": 130, - "endColumn": 22, - "problem": "ClassAsObjectError", - "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", - "severity": "ERROR" - }, - { - "line": 131, - "column": 15, - "endLine": 131, - "endColumn": 21, - "problem": "ClassAsObjectError", - "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", - "severity": "ERROR" - }, { "line": 132, "column": 15, @@ -905,13 +895,13 @@ "severity": "ERROR" }, { - "line": 205, - "column": 87, - "endLine": 205, - "endColumn": 93, - "problem": "ClassAsObjectError", + "line": 209, + "column": 5, + "endLine": 209, + "endColumn": 40, + "problem": "NumericSemantics", "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/class_as_object.ets.json b/ets2panda/linter/test/main/class_as_object.ets.json index cb35d6177679bf650989f405a3789586682d341a..5bfa876a0a6016cbd595b86d7b7b8f93779affe8 100644 --- a/ets2panda/linter/test/main/class_as_object.ets.json +++ b/ets2panda/linter/test/main/class_as_object.ets.json @@ -212,36 +212,6 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "WARNING" }, - { - "line": 129, - "column": 15, - "endLine": 129, - "endColumn": 21, - "problem": "ClassAsObject", - "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", - "severity": "WARNING" - }, - { - "line": 130, - "column": 15, - "endLine": 130, - "endColumn": 22, - "problem": "ClassAsObject", - "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", - "severity": "WARNING" - }, - { - "line": 131, - "column": 15, - "endLine": 131, - "endColumn": 21, - "problem": "ClassAsObject", - "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", - "severity": "WARNING" - }, { "line": 132, "column": 15, @@ -661,16 +631,6 @@ "suggest": "", "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "WARNING" - }, - { - "line": 205, - "column": 87, - "endLine": 205, - "endColumn": 93, - "problem": "ClassAsObject", - "suggest": "", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", - "severity": "WARNING" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/class_no_constructor.ets b/ets2panda/linter/test/main/class_no_constructor.ets index c13aa9b54ab1233ccdae9d6496c2f0e0147d1570..deb0598bc5812f2ca3d2f86f185f3c1020dbd16b 100644 --- a/ets2panda/linter/test/main/class_no_constructor.ets +++ b/ets2panda/linter/test/main/class_no_constructor.ets @@ -17,3 +17,13 @@ class A {} const variable = new A().constructor + +let a = new A() +console.log(a.constructor + ""); + +function foo3(): A { + return new A(); +} +console.log(foo3().constructor + ""); + +console.log(A.constructor + ""); \ No newline at end of file diff --git a/ets2panda/linter/test/main/class_no_constructor.ets.arkts2.json b/ets2panda/linter/test/main/class_no_constructor.ets.arkts2.json index 12f07f6aefeab765323013130ba3901be22f8c2f..940e32b5f0db67161e3a9f6e0e07d54293a1c577 100644 --- a/ets2panda/linter/test/main/class_no_constructor.ets.arkts2.json +++ b/ets2panda/linter/test/main/class_no_constructor.ets.arkts2.json @@ -21,7 +21,37 @@ "endColumn": 37, "problem": "NoConstructorOnClass", "suggest": "", - "rule": "The Class object does not have a constructor. (arkts-no-arkts-constructor)", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 13, + "endLine": 22, + "endColumn": 26, + "problem": "NoConstructorOnClass", + "suggest": "", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 13, + "endLine": 27, + "endColumn": 31, + "problem": "NoConstructorOnClass", + "suggest": "", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 13, + "endLine": 29, + "endColumn": 26, + "problem": "NoConstructorOnClass", + "suggest": "", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/class_no_constructor.ets.migrate.ets b/ets2panda/linter/test/main/class_no_constructor.ets.migrate.ets index c13aa9b54ab1233ccdae9d6496c2f0e0147d1570..deb0598bc5812f2ca3d2f86f185f3c1020dbd16b 100644 --- a/ets2panda/linter/test/main/class_no_constructor.ets.migrate.ets +++ b/ets2panda/linter/test/main/class_no_constructor.ets.migrate.ets @@ -17,3 +17,13 @@ class A {} const variable = new A().constructor + +let a = new A() +console.log(a.constructor + ""); + +function foo3(): A { + return new A(); +} +console.log(foo3().constructor + ""); + +console.log(A.constructor + ""); \ No newline at end of file diff --git a/ets2panda/linter/test/main/class_no_constructor.ets.migrate.json b/ets2panda/linter/test/main/class_no_constructor.ets.migrate.json index 12f07f6aefeab765323013130ba3901be22f8c2f..940e32b5f0db67161e3a9f6e0e07d54293a1c577 100644 --- a/ets2panda/linter/test/main/class_no_constructor.ets.migrate.json +++ b/ets2panda/linter/test/main/class_no_constructor.ets.migrate.json @@ -21,7 +21,37 @@ "endColumn": 37, "problem": "NoConstructorOnClass", "suggest": "", - "rule": "The Class object does not have a constructor. (arkts-no-arkts-constructor)", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 13, + "endLine": 22, + "endColumn": 26, + "problem": "NoConstructorOnClass", + "suggest": "", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 13, + "endLine": 27, + "endColumn": 31, + "problem": "NoConstructorOnClass", + "suggest": "", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 13, + "endLine": 29, + "endColumn": 26, + "problem": "NoConstructorOnClass", + "suggest": "", + "rule": "Objects have no constructor property in ArkTS1.2 (arkts-obj-no-constructor)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/class_static_init.ets.arkts2.json b/ets2panda/linter/test/main/class_static_init.ets.arkts2.json old mode 100755 new mode 100644 index 17db245900a4df3e63c8fb82090b3ba1c3d0e4a1..da2a0d8e4bbd572b5ee5126ef5bc6d2027f4a4c1 --- a/ets2panda/linter/test/main/class_static_init.ets.arkts2.json +++ b/ets2panda/linter/test/main/class_static_init.ets.arkts2.json @@ -501,7 +501,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -511,7 +511,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -521,7 +521,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -531,7 +531,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/comment_test.ets b/ets2panda/linter/test/main/comment_test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3731be6780b463c034d4600620956d2c92f5d13b --- /dev/null +++ b/ets2panda/linter/test/main/comment_test.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class TestClass { + /** + * This is a comment. + */ + property = 123; // This is a comment. + // This is a comment. + arr = [1, 0]; // This is a comment. +} diff --git a/ets2panda/linter/test/main/comment_test.ets.args.json b/ets2panda/linter/test/main/comment_test.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..ef3938e967322a0c7551d84c7b6d280de94144c8 --- /dev/null +++ b/ets2panda/linter/test/main/comment_test.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/comment_test.ets.arkts2.json b/ets2panda/linter/test/main/comment_test.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..76f0d20523993d26b9d5aead29aac54ed054da35 --- /dev/null +++ b/ets2panda/linter/test/main/comment_test.ets.arkts2.json @@ -0,0 +1,68 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 16, + "endLine": 20, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 12, + "endLine": 22, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 15, + "endLine": 22, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/comment_test.ets.autofix.json b/ets2panda/linter/test/main/comment_test.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..e1951adff8ddddfaedb6f848ebbbffdc784079e6 --- /dev/null +++ b/ets2panda/linter/test/main/comment_test.ets.autofix.json @@ -0,0 +1,123 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 669, + "end": 684, + "replacementText": "property: number = 123;", + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 16, + "endLine": 20, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 680, + "end": 683, + "replacementText": "123.0", + "line": 20, + "column": 16, + "endLine": 20, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 737, + "end": 750, + "replacementText": "arr: number[] = [1, 0];", + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 12, + "endLine": 22, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 744, + "end": 745, + "replacementText": "1.0", + "line": 22, + "column": 12, + "endLine": 22, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 15, + "endLine": 22, + "endColumn": 16, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 747, + "end": 748, + "replacementText": "0.0", + "line": 22, + "column": 15, + "endLine": 22, + "endColumn": 16 + } + ], + "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/debugger_statememt.ets.migrate.json b/ets2panda/linter/test/main/comment_test.ets.json similarity index 100% rename from ets2panda/linter/test/main/debugger_statememt.ets.migrate.json rename to ets2panda/linter/test/main/comment_test.ets.json diff --git a/ets2panda/linter/test/main/comment_test.ets.migrate.ets b/ets2panda/linter/test/main/comment_test.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..2131000bfaab3d27e0566c0905210952e99ddce3 --- /dev/null +++ b/ets2panda/linter/test/main/comment_test.ets.migrate.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class TestClass { + /** + * This is a comment. + */ + property: number = 123.0; // This is a comment. + // This is a comment. + arr: number[] = [1.0, 0.0]; // This is a comment. +} diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets.json b/ets2panda/linter/test/main/comment_test.ets.migrate.json similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets.json rename to ets2panda/linter/test/main/comment_test.ets.migrate.json diff --git a/ets2panda/linter/test/main/custom_layout.ets b/ets2panda/linter/test/main/custom_layout.ets index 233a5aaa79d649a1bb3495a25e6cac4ec5b782e9..eb0c300ec863379315cc824d1a5f91875ea6115d 100644 --- a/ets2panda/linter/test/main/custom_layout.ets +++ b/ets2panda/linter/test/main/custom_layout.ets @@ -20,6 +20,7 @@ struct Index { Column() { CustomLayout1({ builder: ColumnChildren }) CustomLayout2({ builder: ColumnChildren }) + CustomLayout3({ builder: ColumnChildren }) } } } @@ -94,7 +95,44 @@ struct CustomLayout2 { @Component struct CustomLayout3 { - build { + @Builder + doNothingBuilder() { + }; + + @BuilderParam builder: () => void = this.doNothingBuilder; + @State startSize: number = 100; + result: SizeResult = { + width: 0, + height: 0 + }; + + onMeasureSize(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let size = 100; + children.forEach((child) => { + let result: MeasureResult = child.measure({ minHeight: size, minWidth: size, maxWidth: size, maxHeight: size }) + size += result.width / 2; + }) + this.result.width = 100; + this.result.height = 400; + return this.result; + } + + onPlaceChildren(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let startPos = 300; + children.forEach((child) => { + let pos = startPos - child.measureResult.height; + child.layout({ x: pos, y: pos }) + }) + } + + build() { + this.builder() + } +} + +@Component +struct CustomLayout4 { + build() { } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json index 32ddf7ff59f064b474e0b4aed22002fead6accf4..afc0270a6457ad39dcf01aa5d50e4eda3d3181f4 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json +++ b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 29, + "line": 30, "column": 12, - "endLine": 29, + "endLine": 30, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 15, - "endLine": 29, + "endLine": 30, "endColumn": 16, "problem": "NumericSemantics", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 18, - "endLine": 29, + "endLine": 30, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 17, - "endLine": 31, + "endLine": 32, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 14, - "endLine": 32, + "endLine": 33, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 15, - "endLine": 33, + "endLine": 34, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 34, + "line": 35, "column": 20, - "endLine": 34, + "endLine": 35, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 20, - "endLine": 35, + "endLine": 36, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 27, - "endLine": 35, + "endLine": 36, "endColumn": 29, "problem": "NumericSemantics", "suggest": "", @@ -105,19 +105,19 @@ "severity": "ERROR" }, { - "line": 40, + "line": 41, "column": 8, - "endLine": 40, + "endLine": 41, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 46, + "line": 47, "column": 30, - "endLine": 46, + "endLine": 47, "endColumn": 33, "problem": "NumericSemantics", "suggest": "", @@ -125,9 +125,9 @@ "severity": "ERROR" }, { - "line": 48, + "line": 49, "column": 12, - "endLine": 48, + "endLine": 49, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", @@ -135,9 +135,9 @@ "severity": "ERROR" }, { - "line": 49, + "line": 50, "column": 13, - "endLine": 49, + "endLine": 50, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -145,9 +145,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 9, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -155,9 +155,9 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 20, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +165,9 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, "column": 11, - "endLine": 55, + "endLine": 56, "endColumn": 54, "problem": "NumericSemantics", "suggest": "", @@ -175,19 +175,19 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 8, - "endLine": 66, + "endLine": 67, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 30, - "endLine": 72, + "endLine": 73, "endColumn": 33, "problem": "NumericSemantics", "suggest": "", @@ -195,9 +195,9 @@ "severity": "ERROR" }, { - "line": 74, + "line": 75, "column": 12, - "endLine": 74, + "endLine": 75, "endColumn": 13, "problem": "NumericSemantics", "suggest": "", @@ -205,9 +205,9 @@ "severity": "ERROR" }, { - "line": 75, + "line": 76, "column": 13, - "endLine": 75, + "endLine": 76, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -215,9 +215,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 9, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -225,9 +225,9 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 16, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -235,9 +235,9 @@ "severity": "ERROR" }, { - "line": 82, + "line": 83, "column": 30, - "endLine": 82, + "endLine": 83, "endColumn": 31, "problem": "NumericSemantics", "suggest": "", @@ -245,9 +245,9 @@ "severity": "ERROR" }, { - "line": 85, + "line": 86, "column": 25, - "endLine": 85, + "endLine": 86, "endColumn": 28, "problem": "NumericSemantics", "suggest": "", @@ -255,9 +255,9 @@ "severity": "ERROR" }, { - "line": 86, + "line": 87, "column": 26, - "endLine": 86, + "endLine": 87, "endColumn": 29, "problem": "NumericSemantics", "suggest": "", @@ -266,12 +266,122 @@ }, { "line": 97, - "column": 3, + "column": 8, "endLine": 97, - "endColumn": 8, - "problem": "AnyType", + "endColumn": 21, + "problem": "CustomLayoutNeedAddDecorator", + "suggest": "", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 30, + "endLine": 103, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 12, + "endLine": 105, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 13, + "endLine": 106, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 16, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 30, + "endLine": 113, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 25, + "endLine": 115, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 26, + "endLine": 116, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 9, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 20, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 11, + "endLine": 123, + "endColumn": 54, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { @@ -281,7 +391,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -291,7 +401,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -301,217 +411,337 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 27, + "line": 28, "column": 2, - "endLine": 27, + "endLine": 28, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 3, - "endLine": 29, + "endLine": 30, "endColumn": 10, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 30, + "line": 31, "column": 5, - "endLine": 30, + "endLine": 31, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 39, + "line": 40, "column": 2, - "endLine": 39, + "endLine": 40, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 41, + "line": 42, "column": 4, - "endLine": 41, + "endLine": 42, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 45, + "line": 46, "column": 4, - "endLine": 45, + "endLine": 46, "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 46, + "line": 47, "column": 4, - "endLine": 46, + "endLine": 47, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 47, + "line": 48, "column": 11, - "endLine": 47, + "endLine": 48, "endColumn": 21, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 35, - "endLine": 52, + "endLine": 53, "endColumn": 47, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 65, - "endLine": 52, + "endLine": 53, "endColumn": 75, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Layoutable\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 90, - "endLine": 52, + "endLine": 53, "endColumn": 111, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 65, + "line": 66, "column": 2, - "endLine": 65, + "endLine": 66, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 67, + "line": 68, "column": 4, - "endLine": 67, + "endLine": 68, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 4, - "endLine": 71, + "endLine": 72, "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 4, - "endLine": 72, + "endLine": 73, "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 73, + "line": 74, "column": 11, - "endLine": 73, + "endLine": 74, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 33, + "endLine": 79, + "endColumn": 45, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 63, + "endLine": 79, + "endColumn": 73, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Measurable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 88, + "endLine": 79, + "endColumn": 109, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 19, + "endLine": 82, + "endColumn": 32, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"MeasureResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 2, + "endLine": 96, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 4, + "endLine": 98, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 4, + "endLine": 102, + "endColumn": 16, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 4, + "endLine": 103, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 11, + "endLine": 104, "endColumn": 21, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 33, - "endLine": 78, + "endLine": 109, "endColumn": 45, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 63, - "endLine": 78, + "endLine": 109, "endColumn": 73, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Measurable\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 88, - "endLine": 78, + "endLine": 109, "endColumn": 109, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 81, + "line": 112, "column": 19, - "endLine": 81, + "endLine": 112, "endColumn": 32, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"MeasureResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 35, + "endLine": 120, + "endColumn": 47, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 65, + "endLine": 120, + "endColumn": 75, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Layoutable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 90, + "endLine": 120, + "endColumn": 111, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/custom_layout.ets.autofix.json b/ets2panda/linter/test/main/custom_layout.ets.autofix.json index 889e3da043f798014c3b27fdea9aef9bcc108344..ac5f81be97742e9dc8641a81d0578c5f753e5a6a 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.autofix.json +++ b/ets2panda/linter/test/main/custom_layout.ets.autofix.json @@ -15,19 +15,19 @@ ], "result": [ { - "line": 29, + "line": 30, "column": 12, - "endLine": 29, + "endLine": 30, "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 824, - "end": 825, + "start": 873, + "end": 874, "replacementText": "1.0", - "line": 29, + "line": 30, "column": 12, - "endLine": 29, + "endLine": 30, "endColumn": 13 } ], @@ -36,19 +36,19 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 15, - "endLine": 29, + "endLine": 30, "endColumn": 16, "problem": "NumericSemantics", "autofix": [ { - "start": 827, - "end": 828, + "start": 876, + "end": 877, "replacementText": "2.0", - "line": 29, + "line": 30, "column": 15, - "endLine": 29, + "endLine": 30, "endColumn": 16 } ], @@ -57,19 +57,19 @@ "severity": "ERROR" }, { - "line": 29, + "line": 30, "column": 18, - "endLine": 29, + "endLine": 30, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 830, - "end": 831, + "start": 879, + "end": 880, "replacementText": "3.0", - "line": 29, + "line": 30, "column": 18, - "endLine": 29, + "endLine": 30, "endColumn": 19 } ], @@ -78,19 +78,19 @@ "severity": "ERROR" }, { - "line": 31, + "line": 32, "column": 17, - "endLine": 31, + "endLine": 32, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 914, - "end": 916, + "start": 963, + "end": 965, "replacementText": "30.0", - "line": 31, + "line": 32, "column": 17, - "endLine": 31, + "endLine": 32, "endColumn": 19 } ], @@ -99,19 +99,19 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 14, - "endLine": 32, + "endLine": 33, "endColumn": 17, "problem": "NumericSemantics", "autofix": [ { - "start": 931, - "end": 934, + "start": 980, + "end": 983, "replacementText": "100.0", - "line": 32, + "line": 33, "column": 14, - "endLine": 32, + "endLine": 33, "endColumn": 17 } ], @@ -120,19 +120,19 @@ "severity": "ERROR" }, { - "line": 33, + "line": 34, "column": 15, - "endLine": 33, + "endLine": 34, "endColumn": 18, "problem": "NumericSemantics", "autofix": [ { - "start": 950, - "end": 953, + "start": 999, + "end": 1002, "replacementText": "100.0", - "line": 33, + "line": 34, "column": 15, - "endLine": 33, + "endLine": 34, "endColumn": 18 } ], @@ -141,19 +141,19 @@ "severity": "ERROR" }, { - "line": 34, + "line": 35, "column": 20, - "endLine": 34, + "endLine": 35, "endColumn": 21, "problem": "NumericSemantics", "autofix": [ { - "start": 974, - "end": 975, + "start": 1023, + "end": 1024, "replacementText": "2.0", - "line": 34, + "line": 35, "column": 20, - "endLine": 34, + "endLine": 35, "endColumn": 21 } ], @@ -162,19 +162,19 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 20, - "endLine": 35, + "endLine": 36, "endColumn": 22, "problem": "NumericSemantics", "autofix": [ { - "start": 996, - "end": 998, + "start": 1045, + "end": 1047, "replacementText": "10.0", - "line": 35, + "line": 36, "column": 20, - "endLine": 35, + "endLine": 36, "endColumn": 22 } ], @@ -183,19 +183,19 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 27, - "endLine": 35, + "endLine": 36, "endColumn": 29, "problem": "NumericSemantics", "autofix": [ { - "start": 1003, - "end": 1005, + "start": 1052, + "end": 1054, "replacementText": "20.0", - "line": 35, + "line": 36, "column": 27, - "endLine": 35, + "endLine": 36, "endColumn": 29 } ], @@ -204,40 +204,40 @@ "severity": "ERROR" }, { - "line": 40, + "line": 41, "column": 8, - "endLine": 40, + "endLine": 41, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "autofix": [ { - "start": 1027, - "end": 1027, - "replacementText": "\n@Layoutable", - "line": 40, + "start": 1076, + "end": 1076, + "replacementText": "\n@CustomLayout", + "line": 41, "column": 8, - "endLine": 40, + "endLine": 41, "endColumn": 21 } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 46, + "line": 47, "column": 30, - "endLine": 46, + "endLine": 47, "endColumn": 33, "problem": "NumericSemantics", "autofix": [ { - "start": 1181, - "end": 1184, + "start": 1230, + "end": 1233, "replacementText": "100.0", - "line": 46, + "line": 47, "column": 30, - "endLine": 46, + "endLine": 47, "endColumn": 33 } ], @@ -246,19 +246,19 @@ "severity": "ERROR" }, { - "line": 48, + "line": 49, "column": 12, - "endLine": 48, + "endLine": 49, "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 1222, - "end": 1223, + "start": 1271, + "end": 1272, "replacementText": "0.0", - "line": 48, + "line": 49, "column": 12, - "endLine": 48, + "endLine": 49, "endColumn": 13 } ], @@ -267,19 +267,19 @@ "severity": "ERROR" }, { - "line": 49, + "line": 50, "column": 13, - "endLine": 49, + "endLine": 50, "endColumn": 14, "problem": "NumericSemantics", "autofix": [ { - "start": 1237, - "end": 1238, + "start": 1286, + "end": 1287, "replacementText": "0.0", - "line": 49, + "line": 50, "column": 13, - "endLine": 49, + "endLine": 50, "endColumn": 14 } ], @@ -288,19 +288,19 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 9, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "autofix": [ { - "start": 1367, - "end": 1381, + "start": 1416, + "end": 1430, "replacementText": "startPos: number = 300", - "line": 53, + "line": 54, "column": 9, - "endLine": 53, + "endLine": 54, "endColumn": 23 } ], @@ -309,19 +309,19 @@ "severity": "ERROR" }, { - "line": 53, + "line": 54, "column": 20, - "endLine": 53, + "endLine": 54, "endColumn": 23, "problem": "NumericSemantics", "autofix": [ { - "start": 1378, - "end": 1381, + "start": 1427, + "end": 1430, "replacementText": "300.0", - "line": 53, + "line": 54, "column": 20, - "endLine": 53, + "endLine": 54, "endColumn": 23 } ], @@ -330,19 +330,19 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, "column": 11, - "endLine": 55, + "endLine": 56, "endColumn": 54, "problem": "NumericSemantics", "autofix": [ { - "start": 1427, - "end": 1470, + "start": 1476, + "end": 1519, "replacementText": "pos: number = startPos - child.measureResult.height", - "line": 55, + "line": 56, "column": 11, - "endLine": 55, + "endLine": 56, "endColumn": 54 } ], @@ -351,40 +351,40 @@ "severity": "ERROR" }, { - "line": 66, + "line": 67, "column": 8, - "endLine": 66, + "endLine": 67, "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "autofix": [ { - "start": 1571, - "end": 1571, - "replacementText": "\n@Layoutable", - "line": 66, + "start": 1620, + "end": 1620, + "replacementText": "\n@CustomLayout", + "line": 67, "column": 8, - "endLine": 66, + "endLine": 67, "endColumn": 21 } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@Layoutable\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 30, - "endLine": 72, + "endLine": 73, "endColumn": 33, "problem": "NumericSemantics", "autofix": [ { - "start": 1725, - "end": 1728, + "start": 1774, + "end": 1777, "replacementText": "100.0", - "line": 72, + "line": 73, "column": 30, - "endLine": 72, + "endLine": 73, "endColumn": 33 } ], @@ -393,19 +393,19 @@ "severity": "ERROR" }, { - "line": 74, + "line": 75, "column": 12, - "endLine": 74, + "endLine": 75, "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 1766, - "end": 1767, + "start": 1815, + "end": 1816, "replacementText": "0.0", - "line": 74, + "line": 75, "column": 12, - "endLine": 74, + "endLine": 75, "endColumn": 13 } ], @@ -414,19 +414,19 @@ "severity": "ERROR" }, { - "line": 75, + "line": 76, "column": 13, - "endLine": 75, + "endLine": 76, "endColumn": 14, "problem": "NumericSemantics", "autofix": [ { - "start": 1781, - "end": 1782, + "start": 1830, + "end": 1831, "replacementText": "0.0", - "line": 75, + "line": 76, "column": 13, - "endLine": 75, + "endLine": 76, "endColumn": 14 } ], @@ -435,19 +435,19 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 9, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 1909, - "end": 1919, + "start": 1958, + "end": 1968, "replacementText": "size: number = 100", - "line": 79, + "line": 80, "column": 9, - "endLine": 79, + "endLine": 80, "endColumn": 19 } ], @@ -456,19 +456,19 @@ "severity": "ERROR" }, { - "line": 79, + "line": 80, "column": 16, - "endLine": 79, + "endLine": 80, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 1916, - "end": 1919, + "start": 1965, + "end": 1968, "replacementText": "100.0", - "line": 79, + "line": 80, "column": 16, - "endLine": 79, + "endLine": 80, "endColumn": 19 } ], @@ -477,19 +477,19 @@ "severity": "ERROR" }, { - "line": 82, + "line": 83, "column": 30, - "endLine": 82, + "endLine": 83, "endColumn": 31, "problem": "NumericSemantics", "autofix": [ { - "start": 2102, - "end": 2103, + "start": 2151, + "end": 2152, "replacementText": "2.0", - "line": 82, + "line": 83, "column": 30, - "endLine": 82, + "endLine": 83, "endColumn": 31 } ], @@ -498,19 +498,19 @@ "severity": "ERROR" }, { - "line": 85, + "line": 86, "column": 25, - "endLine": 85, + "endLine": 86, "endColumn": 28, "problem": "NumericSemantics", "autofix": [ { - "start": 2143, - "end": 2146, + "start": 2192, + "end": 2195, "replacementText": "100.0", - "line": 85, + "line": 86, "column": 25, - "endLine": 85, + "endLine": 86, "endColumn": 28 } ], @@ -519,19 +519,19 @@ "severity": "ERROR" }, { - "line": 86, + "line": 87, "column": 26, - "endLine": 86, + "endLine": 87, "endColumn": 29, "problem": "NumericSemantics", "autofix": [ { - "start": 2173, - "end": 2176, + "start": 2222, + "end": 2225, "replacementText": "400.0", - "line": 86, + "line": 87, "column": 26, - "endLine": 86, + "endLine": 87, "endColumn": 29 } ], @@ -541,228 +541,470 @@ }, { "line": 97, - "column": 3, + "column": 8, "endLine": 97, - "endColumn": 8, - "problem": "AnyType", + "endColumn": 21, + "problem": "CustomLayoutNeedAddDecorator", + "autofix": [ + { + "start": 2304, + "end": 2304, + "replacementText": "\n@CustomLayout", + "line": 97, + "column": 8, + "endLine": 97, + "endColumn": 21 + } + ], "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { - "line": 16, - "column": 2, - "endLine": 16, - "endColumn": 7, - "problem": "UIInterfaceImport", + "line": 103, + "column": 30, + "endLine": 103, + "endColumn": 33, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2458, + "end": 2461, + "replacementText": "100.0", + "line": 103, + "column": 30, + "endLine": 103, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 17, - "column": 2, - "endLine": 17, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 105, + "column": 12, + "endLine": 105, + "endColumn": 13, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2499, + "end": 2500, + "replacementText": "0.0", + "line": 105, + "column": 12, + "endLine": 105, + "endColumn": 13 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 106, + "column": 13, + "endLine": 106, + "endColumn": 14, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2514, + "end": 2515, + "replacementText": "0.0", + "line": 106, + "column": 13, + "endLine": 106, + "endColumn": 14 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 27, - "column": 2, - "endLine": 27, - "endColumn": 9, - "problem": "UIInterfaceImport", + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2642, + "end": 2652, + "replacementText": "size: number = 100", + "line": 110, + "column": 9, + "endLine": 110, + "endColumn": 19 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 29, - "column": 3, - "endLine": 29, - "endColumn": 10, - "problem": "UIInterfaceImport", + "line": 110, + "column": 16, + "endLine": 110, + "endColumn": 19, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2649, + "end": 2652, + "replacementText": "100.0", + "line": 110, + "column": 16, + "endLine": 110, + "endColumn": 19 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 30, - "column": 5, - "endLine": 30, - "endColumn": 9, - "problem": "UIInterfaceImport", + "line": 113, + "column": 30, + "endLine": 113, + "endColumn": 31, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2835, + "end": 2836, + "replacementText": "2.0", + "line": 113, + "column": 30, + "endLine": 113, + "endColumn": 31 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 39, - "column": 2, - "endLine": 39, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 115, + "column": 25, + "endLine": 115, + "endColumn": 28, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2869, + "end": 2872, + "replacementText": "100.0", + "line": 115, + "column": 25, + "endLine": 115, + "endColumn": 28 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 41, - "column": 4, - "endLine": 41, - "endColumn": 11, - "problem": "UIInterfaceImport", + "line": 116, + "column": 26, + "endLine": 116, + "endColumn": 29, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 2899, + "end": 2902, + "replacementText": "400.0", + "line": 116, + "column": 26, + "endLine": 116, + "endColumn": 29 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 45, - "column": 4, - "endLine": 45, - "endColumn": 16, - "problem": "UIInterfaceImport", + "line": 121, + "column": 9, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", "autofix": [ { - "start": 603, - "end": 603, - "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, - "column": 2, - "endLine": 95, - "endColumn": 11 + "start": 3055, + "end": 3069, + "replacementText": "startPos: number = 300", + "line": 121, + "column": 9, + "endLine": 121, + "endColumn": 23 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 46, + "line": 121, + "column": 20, + "endLine": 121, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3066, + "end": 3069, + "replacementText": "300.0", + "line": 121, + "column": 20, + "endLine": 121, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 11, + "endLine": 123, + "endColumn": 54, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3115, + "end": 3158, + "replacementText": "pos: number = startPos - child.measureResult.height", + "line": 123, + "column": 11, + "endLine": 123, + "endColumn": 54 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 2, + "endLine": 28, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 3, + "endLine": 30, + "endColumn": 10, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 2, + "endLine": 40, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 4, + "endLine": 42, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, "column": 4, "endLine": 46, - "endColumn": 9, + "endColumn": 16, "problem": "UIInterfaceImport", "autofix": [ { "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { "line": 47, - "column": 11, + "column": 4, "endLine": 47, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 11, + "endLine": 48, "endColumn": 21, "problem": "UIInterfaceImport", "autofix": [ @@ -770,20 +1012,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 35, - "endLine": 52, + "endLine": 53, "endColumn": 47, "problem": "UIInterfaceImport", "autofix": [ @@ -791,20 +1033,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 65, - "endLine": 52, + "endLine": 53, "endColumn": 75, "problem": "UIInterfaceImport", "autofix": [ @@ -812,20 +1054,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Layoutable\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 52, + "line": 53, "column": 90, - "endLine": 52, + "endLine": 53, "endColumn": 111, "problem": "UIInterfaceImport", "autofix": [ @@ -833,20 +1075,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 65, + "line": 66, "column": 2, - "endLine": 65, + "endLine": 66, "endColumn": 11, "problem": "UIInterfaceImport", "autofix": [ @@ -854,20 +1096,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 67, + "line": 68, "column": 4, - "endLine": 67, + "endLine": 68, "endColumn": 11, "problem": "UIInterfaceImport", "autofix": [ @@ -875,20 +1117,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 71, + "line": 72, "column": 4, - "endLine": 71, + "endLine": 72, "endColumn": 16, "problem": "UIInterfaceImport", "autofix": [ @@ -896,20 +1138,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 4, - "endLine": 72, + "endLine": 73, "endColumn": 9, "problem": "UIInterfaceImport", "autofix": [ @@ -917,20 +1159,209 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 73, + "line": 74, "column": 11, - "endLine": 73, + "endLine": 74, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 33, + "endLine": 79, + "endColumn": 45, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 63, + "endLine": 79, + "endColumn": 73, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Measurable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 88, + "endLine": 79, + "endColumn": 109, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 19, + "endLine": 82, + "endColumn": 32, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"MeasureResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 2, + "endLine": 96, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 4, + "endLine": 98, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Builder\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 4, + "endLine": 102, + "endColumn": 16, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 4, + "endLine": 103, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 11, + "endLine": 104, "endColumn": 21, "problem": "UIInterfaceImport", "autofix": [ @@ -938,20 +1369,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SizeResult\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 33, - "endLine": 78, + "endLine": 109, "endColumn": 45, "problem": "UIInterfaceImport", "autofix": [ @@ -959,20 +1390,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 63, - "endLine": 78, + "endLine": 109, "endColumn": 73, "problem": "UIInterfaceImport", "autofix": [ @@ -980,20 +1411,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Measurable\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 78, + "line": 109, "column": 88, - "endLine": 78, + "endLine": 109, "endColumn": 109, "problem": "UIInterfaceImport", "autofix": [ @@ -1001,20 +1432,20 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 81, + "line": 112, "column": 19, - "endLine": 81, + "endLine": 112, "endColumn": 32, "problem": "UIInterfaceImport", "autofix": [ @@ -1022,20 +1453,83 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"MeasureResult\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 35, + "endLine": 120, + "endColumn": 47, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"GeometryInfo\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 65, + "endLine": 120, + "endColumn": 75, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, + "column": 2, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Layoutable\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 90, + "endLine": 120, + "endColumn": 111, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ConstraintSizeOptions\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11, "problem": "UIInterfaceImport", "autofix": [ @@ -1043,14 +1537,14 @@ "start": 603, "end": 603, "replacementText": "\n\nimport { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI';", - "line": 95, + "line": 133, "column": 2, - "endLine": 95, + "endLine": 133, "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/custom_layout.ets.json b/ets2panda/linter/test/main/custom_layout.ets.json index 5d769b466be894ca7e944a9048b170f15ac0ae1c..cc51fe6a1b8579dfc9a96d92c8fb908c4660e35a 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.json +++ b/ets2panda/linter/test/main/custom_layout.ets.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 78, + "line": 79, "column": 3, - "endLine": 78, + "endLine": 79, "endColumn": 16, "problem": "LimitedReturnTypeInference", "suggest": "", @@ -25,13 +25,13 @@ "severity": "ERROR" }, { - "line": 97, + "line": 109, "column": 3, - "endLine": 97, - "endColumn": 8, - "problem": "AnyType", + "endLine": 109, + "endColumn": 16, + "problem": "LimitedReturnTypeInference", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/custom_layout.ets.migrate.ets b/ets2panda/linter/test/main/custom_layout.ets.migrate.ets index 97dd101026b6341d1c89f2b955d001b79a3e420d..5053380e4c88ac8b5a22585630602e23ec549ef2 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.migrate.ets +++ b/ets2panda/linter/test/main/custom_layout.ets.migrate.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +import { CustomLayout } from '@kit.ArkUI'; + import { Entry, Component, Column, Builder, ForEach, Text, BuilderParam, State, SizeResult, GeometryInfo, Layoutable, ConstraintSizeOptions, Measurable, MeasureResult } from '@kit.ArkUI'; @Entry @@ -22,6 +24,7 @@ struct Index { Column() { CustomLayout1({ builder: ColumnChildren }) CustomLayout2({ builder: ColumnChildren }) + CustomLayout3({ builder: ColumnChildren }) } } } @@ -39,7 +42,7 @@ function ColumnChildren() { } @Component -@Layoutable +@CustomLayout struct CustomLayout1 { @Builder doNothingBuilder() { @@ -66,7 +69,7 @@ struct CustomLayout1 { } @Component -@Layoutable +@CustomLayout struct CustomLayout2 { @Builder doNothingBuilder() { @@ -97,8 +100,46 @@ struct CustomLayout2 { } @Component +@CustomLayout struct CustomLayout3 { - build { + @Builder + doNothingBuilder() { + }; + + @BuilderParam builder: () => void = this.doNothingBuilder; + @State startSize: number = 100.0; + result: SizeResult = { + width: 0.0, + height: 0.0 + }; + + onMeasureSize(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let size: number = 100.0; + children.forEach((child) => { + let result: MeasureResult = child.measure({ minHeight: size, minWidth: size, maxWidth: size, maxHeight: size }) + size += result.width / 2.0; + }) + this.result.width = 100.0; + this.result.height = 400.0; + return this.result; + } + + onPlaceChildren(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions) { + let startPos: number = 300.0; + children.forEach((child) => { + let pos: number = startPos - child.measureResult.height; + child.layout({ x: pos, y: pos }) + }) + } + + build() { + this.builder() + } +} + +@Component +struct CustomLayout4 { + build() { } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/custom_layout.ets.migrate.json b/ets2panda/linter/test/main/custom_layout.ets.migrate.json index 6c283c3ef1beea2a8d290ae40cecd19853e44771..21ac1fc70cfda7b0747e4d1f3deda42f66986334 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.migrate.json +++ b/ets2panda/linter/test/main/custom_layout.ets.migrate.json @@ -15,33 +15,33 @@ ], "result": [ { - "line": 42, + "line": 45, "column": 1, - "endLine": 42, - "endColumn": 12, + "endLine": 45, + "endColumn": 14, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" }, { - "line": 69, + "line": 72, "column": 1, - "endLine": 69, - "endColumn": 12, + "endLine": 72, + "endColumn": 14, "problem": "DecoratorsNotSupported", "suggest": "", "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" }, { - "line": 101, - "column": 3, - "endLine": 101, - "endColumn": 8, - "problem": "AnyType", + "line": 103, + "column": 1, + "endLine": 103, + "endColumn": 14, + "problem": "DecoratorsNotSupported", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/debugger_statememt.ets.args.json b/ets2panda/linter/test/main/debugger_statememt.ets.args.json index f56752f2284e65fb08a317502e548ab26eee7c70..4acc088d1da62353e56ced57f16b342de413cb78 100644 --- a/ets2panda/linter/test/main/debugger_statememt.ets.args.json +++ b/ets2panda/linter/test/main/debugger_statememt.ets.args.json @@ -14,8 +14,6 @@ "limitations under the License." ], "mode": { - "arkts2": "", - "autofix": "--arkts-2", - "migrate": "--arkts-2" + "arkts2": "" } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/debugger_statememt.ets.arkts2.json b/ets2panda/linter/test/main/debugger_statememt.ets.arkts2.json index a220a0103848419c575b937bb62dcb1a48c52321..09196c4c33797d9039007a0c93c4bd3571c6e3b3 100644 --- a/ets2panda/linter/test/main/debugger_statememt.ets.arkts2.json +++ b/ets2panda/linter/test/main/debugger_statememt.ets.arkts2.json @@ -21,7 +21,7 @@ "endColumn": 10, "problem": "DebuggerStatement", "suggest": "", - "rule": "\"debugger\" is not supported (arkts-no-debugger-stmt)", + "rule": "\"debugger\" is not supported (arkts-no-debugger)", "severity": "ERROR" }, { @@ -31,7 +31,7 @@ "endColumn": 12, "problem": "DebuggerStatement", "suggest": "", - "rule": "\"debugger\" is not supported (arkts-no-debugger-stmt)", + "rule": "\"debugger\" is not supported (arkts-no-debugger)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/default_required_args.ets b/ets2panda/linter/test/main/default_required_args.ets index cbccdb42cf31c8bdadd160e270814f14ec671829..613b5ac307b2e9511bb410529417538300235a77 100644 --- a/ets2panda/linter/test/main/default_required_args.ets +++ b/ets2panda/linter/test/main/default_required_args.ets @@ -57,4 +57,17 @@ function log(level: string = 'info', some: string, message?: string): void { function config(debug: boolean = true, verbose?: boolean): string { //legal return `Debug: ${debug ?? false}, Verbose: ${verbose ?? false}`; +} + +export class DefaultArgsA { + readonly left: number; + readonly right: number; + constructor(left: number = 0.0, right: number) { // 漏扫 + this.left = left; + this.right = right; + } + + defaultArgsFoo1(left: number = 0.0, right: number): number { + return left + right; + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/default_required_args.ets.arkts2.json b/ets2panda/linter/test/main/default_required_args.ets.arkts2.json index bbcdfcb08550783a6ee99afe23bf3147a0334e5f..33a446a7017acd20152c663e8960786dc2be8dd3 100644 --- a/ets2panda/linter/test/main/default_required_args.ets.arkts2.json +++ b/ets2panda/linter/test/main/default_required_args.ets.arkts2.json @@ -173,6 +173,26 @@ "suggest": "", "rule": "Default parameters must be placed after mandatory parameters (arkts-default-args-behind-required-args)", "severity": "ERROR" + }, + { + "line": 65, + "column": 15, + "endLine": 65, + "endColumn": 19, + "problem": "DefaultArgsBehindRequiredArgs", + "suggest": "", + "rule": "Default parameters must be placed after mandatory parameters (arkts-default-args-behind-required-args)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 19, + "endLine": 70, + "endColumn": 23, + "problem": "DefaultArgsBehindRequiredArgs", + "suggest": "", + "rule": "Default parameters must be placed after mandatory parameters (arkts-default-args-behind-required-args)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/dollar_binding_1.ets.arkts2.json b/ets2panda/linter/test/main/dollar_binding_1.ets.arkts2.json index 674cd0d86840389cbd363d0f9601084eb9f32331..0370cab2573504fddf756a53ebae44ded3f454bc 100644 --- a/ets2panda/linter/test/main/dollar_binding_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/dollar_binding_1.ets.arkts2.json @@ -61,7 +61,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Link\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/dollar_binding_1.ets.autofix.json b/ets2panda/linter/test/main/dollar_binding_1.ets.autofix.json index 3081866ef6d24a3931db204b35cdb51f8e98e37d..3987f67867c3227b9ec63f307136751555ce896f 100644 --- a/ets2panda/linter/test/main/dollar_binding_1.ets.autofix.json +++ b/ets2panda/linter/test/main/dollar_binding_1.ets.autofix.json @@ -116,7 +116,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -137,7 +137,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -158,7 +158,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -179,7 +179,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -200,7 +200,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Link\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -242,7 +242,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -263,7 +263,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/double_dollar_binding_1.ets.arkts2.json b/ets2panda/linter/test/main/double_dollar_binding_1.ets.arkts2.json index f62cf13942a130fbec139962a797ac8a2c2be275..6fcb57db65f61bda6fcb1b8eb3d387027ff829ee 100644 --- a/ets2panda/linter/test/main/double_dollar_binding_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/double_dollar_binding_1.ets.arkts2.json @@ -51,7 +51,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 15, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Checkbox\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 12, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/double_dollar_binding_1.ets.autofix.json b/ets2panda/linter/test/main/double_dollar_binding_1.ets.autofix.json index 7a7748866b57036663b876c85f319174f3ad95ed..b76e000be1caf4b31eb1bbc41047353959c57d76 100644 --- a/ets2panda/linter/test/main/double_dollar_binding_1.ets.autofix.json +++ b/ets2panda/linter/test/main/double_dollar_binding_1.ets.autofix.json @@ -95,7 +95,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -116,7 +116,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -137,7 +137,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -158,7 +158,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -179,7 +179,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -200,7 +200,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -242,7 +242,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Checkbox\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -263,7 +263,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -284,7 +284,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/double_excla_binding_1.ets.arkts2.json b/ets2panda/linter/test/main/double_excla_binding_1.ets.arkts2.json index 1049eb7c5c4dee94d8d7d448974569ee75c9a99a..96a079fe66137bf24c5c06d77bea6dfa0e25bbda 100644 --- a/ets2panda/linter/test/main/double_excla_binding_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/double_excla_binding_1.ets.arkts2.json @@ -131,7 +131,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -151,7 +151,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -161,7 +161,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -171,7 +171,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -181,7 +181,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -191,7 +191,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -201,7 +201,7 @@ "endColumn": 15, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Checkbox\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -211,7 +211,7 @@ "endColumn": 12, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -231,7 +231,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -241,7 +241,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -251,7 +251,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -261,7 +261,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -271,7 +271,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -281,7 +281,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -291,7 +291,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -301,7 +301,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -311,7 +311,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -321,7 +321,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -331,7 +331,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -341,7 +341,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -351,7 +351,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -361,7 +361,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -371,7 +371,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -381,7 +381,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -391,7 +391,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -401,7 +401,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -411,7 +411,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -421,7 +421,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -431,7 +431,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Param\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -441,7 +441,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Event\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -451,7 +451,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -461,7 +461,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -471,7 +471,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json b/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json index b10e76da6e07d88ad1b89779564a1527805f2cf7..4115b5173b06a7ff4b9a61aa2b2e6ea366f0d8f0 100644 --- a/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json +++ b/ets2panda/linter/test/main/double_excla_binding_1.ets.autofix.json @@ -263,7 +263,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -284,7 +284,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -305,7 +305,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -326,7 +326,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -347,7 +347,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -368,7 +368,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -389,7 +389,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -410,7 +410,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Checkbox\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -431,7 +431,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -452,7 +452,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -473,7 +473,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -494,7 +494,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -515,7 +515,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -536,7 +536,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -557,7 +557,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -578,7 +578,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -599,7 +599,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -620,7 +620,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -641,7 +641,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -662,7 +662,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -683,7 +683,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -704,7 +704,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Slider\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -725,7 +725,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -746,7 +746,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -767,7 +767,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -788,7 +788,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -809,7 +809,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -830,7 +830,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -851,7 +851,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -872,7 +872,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -893,7 +893,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Param\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -914,7 +914,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Event\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -935,7 +935,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -956,7 +956,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -977,7 +977,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/double_excla_binding_3.ets b/ets2panda/linter/test/main/double_excla_binding_3.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c9dcc1e87d92cb935d8ab70085acccafdaa580a --- /dev/null +++ b/ets2panda/linter/test/main/double_excla_binding_3.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class User { + name: string = "Jack" +} + +@Entry +@Component +struct MyComponent { + @State user: User = new User() + + build() { + Row() { + Text(this.user!.name) + Text(this.user!!.name) + Text(this.user!!!.name) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/double_excla_binding_3.ets.args.json b/ets2panda/linter/test/main/double_excla_binding_3.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..30973c00a22aa0a072616f644b02c89a4a4dd4fa --- /dev/null +++ b/ets2panda/linter/test/main/double_excla_binding_3.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/double_excla_binding_3.ets.arkts2.json b/ets2panda/linter/test/main/double_excla_binding_3.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..d73e979005ffaa2458d365d61fb1667377f3bd30 --- /dev/null +++ b/ets2panda/linter/test/main/double_excla_binding_3.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 2, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 4, + "endLine": 23, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 7, + "endLine": 28, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/double_excla_binding_3.ets.autofix.json b/ets2panda/linter/test/main/double_excla_binding_3.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..36d4ed45253be119d5ee63f78da8f6d4eae7364f --- /dev/null +++ b/ets2panda/linter/test/main/double_excla_binding_3.ets.autofix.json @@ -0,0 +1,165 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, State, Row, Text } from '@kit.ArkUI';", + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 2, + "endLine": 21, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, State, Row, Text } from '@kit.ArkUI';", + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 4, + "endLine": 23, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, State, Row, Text } from '@kit.ArkUI';", + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 8, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, State, Row, Text } from '@kit.ArkUI';", + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, State, Row, Text } from '@kit.ArkUI';", + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 7, + "endLine": 28, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, State, Row, Text } from '@kit.ArkUI';", + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, State, Row, Text } from '@kit.ArkUI';", + "line": 29, + "column": 7, + "endLine": 29, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/double_excla_binding_3.ets.json b/ets2panda/linter/test/main/double_excla_binding_3.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..b7a8809e02ae14f7f14ed7adbd6d2d3f630fa3f6 --- /dev/null +++ b/ets2panda/linter/test/main/double_excla_binding_3.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/global_this.ets.migrate.ets b/ets2panda/linter/test/main/double_excla_binding_3.ets.migrate.ets similarity index 50% rename from ets2panda/linter/test/main/global_this.ets.migrate.ets rename to ets2panda/linter/test/main/double_excla_binding_3.ets.migrate.ets index aaafd6ebd11b8534e2cd97530cafd75685758d31..b646a64c4944b8f6b18d1952dd0d676e1708bdb6 100644 --- a/ets2panda/linter/test/main/global_this.ets.migrate.ets +++ b/ets2panda/linter/test/main/double_excla_binding_3.ets.migrate.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * 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 @@ -13,29 +13,22 @@ * limitations under the License. */ -const pi: number = 3.1416; +import { Entry, Component, State, Row, Text } from '@kit.ArkUI'; -function circleArea(r: number): number { - foo(globalThis); - - return specialAutofixLib.globalThis.get("pi") * r * r; -} - -function foo(x: any): void { - console.log(x.pi); +class User { + name: string = "Jack" } -specialAutofixLib.globalThis.set("abc", 200.0); - -const value = specialAutofixLib.globalThis.get("obj").prop; - -delete specialAutofixLib.globalThis.get("property"); - -globalThisprop = 100.0; - -specialAutofixLib.globalThis.get("pi"); - -specialAutofixLib.globalThis.set("pi",3.1416); - -specialAutofixLib.globalThis; - +@Entry +@Component +struct MyComponent { + @State user: User = new User() + + build() { + Row() { + Text(this.user!.name) + Text(this.user!!.name) + Text(this.user!!!.name) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/double_excla_binding_3.ets.migrate.json b/ets2panda/linter/test/main/double_excla_binding_3.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..b7a8809e02ae14f7f14ed7adbd6d2d3f630fa3f6 --- /dev/null +++ b/ets2panda/linter/test/main/double_excla_binding_3.ets.migrate.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/dynamic_ctor_call.ets.arkts2.json b/ets2panda/linter/test/main/dynamic_ctor_call.ets.arkts2.json index 0ef26c352d653b6c6e8fd73f0070ea28f6847bbe..b4ee74500e610e14150f1907769481521dccf99e 100644 --- a/ets2panda/linter/test/main/dynamic_ctor_call.ets.arkts2.json +++ b/ets2panda/linter/test/main/dynamic_ctor_call.ets.arkts2.json @@ -124,6 +124,16 @@ "rule": "Construct signatures are not supported in interfaces (arkts-no-ctor-signatures-iface)", "severity": "ERROR" }, + { + "line": 39, + "column": 14, + "endLine": 39, + "endColumn": 18, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, { "line": 39, "column": 14, diff --git a/ets2panda/linter/test/main/dynamic_import.ets.arkts2.json b/ets2panda/linter/test/main/dynamic_import.ets.arkts2.json index 30c87c82a58444ee99ddbb2374a45de7413dcd21..ae596bc17ecaec6eac5b21c688c4ec0a3ec135f1 100644 --- a/ets2panda/linter/test/main/dynamic_import.ets.arkts2.json +++ b/ets2panda/linter/test/main/dynamic_import.ets.arkts2.json @@ -161,7 +161,7 @@ "endColumn": 76, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"EllipseShape\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/entry_annotation_test8_1.ets.autofix.json b/ets2panda/linter/test/main/entry_annotation_test8_1.ets.autofix.json index c1e82092cbc8411d1014db7524fa9e02b3151d6c..a8450fce0eb32b69920c131fcd15e94c3e8f0550 100644 --- a/ets2panda/linter/test/main/entry_annotation_test8_1.ets.autofix.json +++ b/ets2panda/linter/test/main/entry_annotation_test8_1.ets.autofix.json @@ -20,13 +20,6 @@ "endLine": 18, "endColumn": 39, "problem": "GlobalThisError", - "autofix": [ - { - "start": 700, - "end": 723, - "replacementText": "specialAutofixLib.globalThis.get(\"localStorage\")" - } - ], "suggest": "", "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", "severity": "ERROR" @@ -41,7 +34,11 @@ { "start": 725, "end": 750, - "replacementText": "const __get_local_storage__ = (): LocalStorage => source;\n@Entry({ storage: \"__get_local_storage__\" })" + "replacementText": "const __get_local_storage__ = (): LocalStorage => source;\n@Entry({ storage: \"__get_local_storage__\" })", + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 26 } ], "suggest": "", diff --git a/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.ets b/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.ets index 1159381e1c3c5eae9a51f58e38fae68cb7e2e27a..bf1b217b00c86ec03ce3342cb6a8031456bc3cca 100644 --- a/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.ets +++ b/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.ets @@ -15,8 +15,8 @@ import { Entry, Component, Text, LocalStorage } from '@ohos.arkui.components'; -const source = specialAutofixLib.globalThis.get("localStorage"); -const __get_local_storage__ = (): LocalStorage => source; +const source = globalThis.localStorage; +const __get_local_storage__ = (): LocalStorage => source; @Entry({ storage: "__get_local_storage__" }) @Component struct MyPage { diff --git a/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.json b/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.json index 045feeac1b91ac7e0aaa3fc613760478fdcaa478..8723136274aefa0e120634e1bbe69ddf54a00629 100644 --- a/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.json +++ b/ets2panda/linter/test/main/entry_annotation_test8_1.ets.migrate.json @@ -16,12 +16,12 @@ "result": [ { "line": 18, - "column": 7, + "column": 16, "endLine": 18, - "endColumn": 64, - "problem": "AnyType", + "endColumn": 39, + "problem": "GlobalThisError", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/entry_annotation_test8_2.ets.autofix.json b/ets2panda/linter/test/main/entry_annotation_test8_2.ets.autofix.json index f73277ba2c6e5588e6920e22bfe177ab72d3790a..8723136274aefa0e120634e1bbe69ddf54a00629 100644 --- a/ets2panda/linter/test/main/entry_annotation_test8_2.ets.autofix.json +++ b/ets2panda/linter/test/main/entry_annotation_test8_2.ets.autofix.json @@ -20,13 +20,6 @@ "endLine": 18, "endColumn": 39, "problem": "GlobalThisError", - "autofix": [ - { - "start": 700, - "end": 723, - "replacementText": "specialAutofixLib.globalThis.get(\"localStorage\")" - } - ], "suggest": "", "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", "severity": "ERROR" diff --git a/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.ets b/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.ets index 0c20666abffa48687f2ec8cd3bd6587609d30ff2..1120a5a86040563916efc4fdd7eeba88f852e5ea 100644 --- a/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.ets +++ b/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.ets @@ -15,7 +15,7 @@ import { Entry, Component, Text, LocalStorage } from '@ohos.arkui.components'; -const source = specialAutofixLib.globalThis.get("localStorage"); +const source = globalThis.localStorage; const __get_local_storage__ = (): LocalStorage => source; @Entry({storage: "__get_local_storage__"}) @Component diff --git a/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.json b/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.json index 045feeac1b91ac7e0aaa3fc613760478fdcaa478..8723136274aefa0e120634e1bbe69ddf54a00629 100644 --- a/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.json +++ b/ets2panda/linter/test/main/entry_annotation_test8_2.ets.migrate.json @@ -16,12 +16,12 @@ "result": [ { "line": 18, - "column": 7, + "column": 16, "endLine": 18, - "endColumn": 64, - "problem": "AnyType", + "endColumn": 39, + "problem": "GlobalThisError", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/entry_annotation_test9_1.ets.autofix.json b/ets2panda/linter/test/main/entry_annotation_test9_1.ets.autofix.json index f8e2a1ef6c88975cdd9dfddc0d5cd8451a81ca3b..19bc667ae8ec353640870e909f0936e7c7be9b97 100644 --- a/ets2panda/linter/test/main/entry_annotation_test9_1.ets.autofix.json +++ b/ets2panda/linter/test/main/entry_annotation_test9_1.ets.autofix.json @@ -24,7 +24,11 @@ { "start": 685, "end": 727, - "replacementText": "const __get_local_storage__ = (): LocalStorage => globalThis.localStorage;\n@Entry({ storage: \"__get_local_storage__\" })" + "replacementText": "const __get_local_storage__ = (): LocalStorage => globalThis.localStorage;\n@Entry({ storage: \"__get_local_storage__\" })", + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 43 } ], "suggest": "", @@ -37,13 +41,6 @@ "endLine": 18, "endColumn": 41, "problem": "GlobalThisError", - "autofix": [ - { - "start": 702, - "end": 725, - "replacementText": "specialAutofixLib.globalThis.get(\"localStorage\")" - } - ], "suggest": "", "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", "severity": "ERROR" diff --git a/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.ets b/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.ets index 8c9d2b20122520a1036755a7aab58b9807fc626f..94bcbfdd9b87ddd2bda4692ec11e7d24f8e07082 100644 --- a/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.ets +++ b/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.ets @@ -15,7 +15,7 @@ import { Entry, Component, Text, LocalStorage } from '@ohos.arkui.components'; -const __get_local_storage__ = (): LocalStorage => specialAutofixLib.globalThis.get("localStorage"); +const __get_local_storage__ = (): LocalStorage => globalThis.localStorage; @Entry({ storage: "__get_local_storage__" }) @Component struct MyPage { diff --git a/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.json b/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.json index ca88f857e960b437dcf767c0ac40be998c8f1236..a390c87a2e15b3463edfc5f7a22e9dcaba33afc6 100644 --- a/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.json +++ b/ets2panda/linter/test/main/entry_annotation_test9_1.ets.migrate.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 18, + "column": 51, + "endLine": 18, + "endColumn": 74, + "problem": "GlobalThisError", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/entry_annotation_test9_2.ets.autofix.json b/ets2panda/linter/test/main/entry_annotation_test9_2.ets.autofix.json index 17f6fcde033bbf37a56d9c1ce4d514a029e8e332..a390c87a2e15b3463edfc5f7a22e9dcaba33afc6 100644 --- a/ets2panda/linter/test/main/entry_annotation_test9_2.ets.autofix.json +++ b/ets2panda/linter/test/main/entry_annotation_test9_2.ets.autofix.json @@ -20,13 +20,6 @@ "endLine": 18, "endColumn": 74, "problem": "GlobalThisError", - "autofix": [ - { - "start": 735, - "end": 758, - "replacementText": "specialAutofixLib.globalThis.get(\"localStorage\")" - } - ], "suggest": "", "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", "severity": "ERROR" diff --git a/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.ets b/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.ets index 9f1162ccfd9b4bd32b22eda12ce9773232e37e9b..f6f5bf039ff2d569fd321183011cb8933ab65f24 100644 --- a/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.ets +++ b/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.ets @@ -15,7 +15,7 @@ import { Entry, Component, Text, LocalStorage } from '@ohos.arkui.components'; -const __get_local_storage__ = (): LocalStorage => specialAutofixLib.globalThis.get("localStorage"); +const __get_local_storage__ = (): LocalStorage => globalThis.localStorage; @Entry({storage: "__get_local_storage__"}) @Component struct MyPage { diff --git a/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.json b/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.json index ca88f857e960b437dcf767c0ac40be998c8f1236..a390c87a2e15b3463edfc5f7a22e9dcaba33afc6 100644 --- a/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.json +++ b/ets2panda/linter/test/main/entry_annotation_test9_2.ets.migrate.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 18, + "column": 51, + "endLine": 18, + "endColumn": 74, + "problem": "GlobalThisError", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json b/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json index ff258d6c128395ffaa10c3a1f32fcde5e9e2f7cb..95b3bdaefb784e4a83ae9e14da95ab0063b71d7a 100644 --- a/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json +++ b/ets2panda/linter/test/main/enum_not_support_float.ets.arkts2.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 24, "column": 3, diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json index 6c7ca94b922852b39dbb8edf11e8a67856b34ea0..54fab7a23c30ef326d9e0526f070620f2fe447d4 100755 --- a/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.arkts2.json @@ -224,6 +224,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 133, + "column": 10, + "endLine": 133, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 139, "column": 3, @@ -323,6 +333,16 @@ "suggest": "", "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", "severity": "ERROR" + }, + { + "line": 175, + "column": 1, + "endLine": 175, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json index 6f0f0a04818feb1bc8998c01eb4f2dae5cefcabc..a9ddde793cb408d505707d3da6b43d75c46c228f 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.autofix.json @@ -106,7 +106,7 @@ "problem": "ExplicitFunctionType", "autofix": [ { - "replacementText": "fn.unSafeCall", + "replacementText": "fn.unsafeCall", "start": 1572, "end": 1574, "line": 57, @@ -345,6 +345,27 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 133, + "column": 10, + "endLine": 133, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2849, + "end": 2850, + "replacementText": "1.0", + "line": 133, + "column": 10, + "endLine": 133, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 139, "column": 3, @@ -353,7 +374,7 @@ "problem": "ExplicitFunctionType", "autofix": [ { - "replacementText": "callback.unSafeCall", + "replacementText": "callback.unsafeCall", "start": 2921, "end": 2929, "line": 139, @@ -425,7 +446,7 @@ "problem": "ExplicitFunctionType", "autofix": [ { - "replacementText": "curr.unSafeCall", + "replacementText": "curr.unsafeCall", "start": 3458, "end": 3462, "line": 160, @@ -446,7 +467,7 @@ "problem": "ExplicitFunctionType", "autofix": [ { - "replacementText": "prev.unSafeCall", + "replacementText": "prev.unsafeCall", "start": 3463, "end": 3467, "line": 160, @@ -467,7 +488,7 @@ "problem": "ExplicitFunctionType", "autofix": [ { - "replacementText": "f1.unSafeCall", + "replacementText": "f1.unsafeCall", "start": 3586, "end": 3588, "line": 166, @@ -488,7 +509,7 @@ "problem": "ExplicitFunctionType", "autofix": [ { - "replacementText": "ab3.fn3.unSafeCall", + "replacementText": "ab3.fn3.unsafeCall", "start": 3656, "end": 3663, "line": 172, @@ -509,7 +530,7 @@ "problem": "ExplicitFunctionType", "autofix": [ { - "replacementText": "fn29[1].unSafeCall", + "replacementText": "fn29[1].unsafeCall", "start": 3697, "end": 3704, "line": 175, @@ -521,6 +542,16 @@ "suggest": "", "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", "severity": "ERROR" + }, + { + "line": 175, + "column": 1, + "endLine": 175, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets index 0a5b1a221f4ff54dbded7d2b2c587748901b508a..7d20e3f2295ea59297e3831328b68b9e9c74d821 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets +++ b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.ets @@ -54,7 +54,7 @@ class D5 implements C5 { } function run6(fn: Function) { - fn.unSafeCall(); + fn.unsafeCall(); } function getFunction8(): Function { @@ -130,13 +130,13 @@ let tup38:[['arkts'|Function, 1.0|true, false], string[], Function] = [['arkts', //枚举 enum E39 { Function, - BLUE = 1, + BLUE = 1.0, YELLOW } //回调参数不明确 function handleEvent41(callback: Function) { - callback.unSafeCall("event", Date.now()); + callback.unsafeCall("event", Date.now()); } let fn43: Function = (x: number) => x + 1.0; @@ -157,19 +157,19 @@ const fetchData44: Function = async (url: string) => { //高阶函数 function compose45(...fns: Function[]): Function { - return fns.reduce((prev, curr) => (...args: Function[]) => curr.unSafeCall(prev.unSafeCall(...args)) as Function); + return fns.reduce((prev, curr) => (...args: Function[]) => curr.unsafeCall(prev.unsafeCall(...args)) as Function); } export let add: (a: number, b: number) => number; export let add1: (a: string) => object; -f1.unSafeCall(); +f1.unsafeCall(); class AB3 { fn3: Function = () => {}; } let ab3 = new AB3(); -ab3.fn3.unSafeCall(); +ab3.fn3.unsafeCall(); const fn29: Function[] = []; -fn29[1].unSafeCall(); \ No newline at end of file +fn29[1].unsafeCall(); \ No newline at end of file diff --git a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json index ca5758bca29ec3547fa2ecf15a3320655747c97b..b4e8db486eeaedea242edff205286dd79e155a9f 100644 --- a/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json +++ b/ets2panda/linter/test/main/explicit_function_type.ets.migrate.json @@ -143,6 +143,16 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 175, + "column": 1, + "endLine": 175, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/exponent.ets.autofix.json b/ets2panda/linter/test/main/exponent.ets.autofix.json index ee4e3b46625385ea9fb4c16f906bf1005963b961..cc6218a973907d838d74561163aeb985f0df4a53 100644 --- a/ets2panda/linter/test/main/exponent.ets.autofix.json +++ b/ets2panda/linter/test/main/exponent.ets.autofix.json @@ -231,9 +231,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 721, + "start": 720, "end": 722, - "replacementText": "1.0", + "replacementText": "-1.0", "line": 25, "column": 15, "endLine": 25, diff --git a/ets2panda/linter/test/main/extend_decorator_1.ets.arkts2.json b/ets2panda/linter/test/main/extend_decorator_1.ets.arkts2.json index d35d9872c4271ad275d034cda0702aae22e5b33e..66b998c9439d97268a83f11120c448704ef329ba 100644 --- a/ets2panda/linter/test/main/extend_decorator_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/extend_decorator_1.ets.arkts2.json @@ -91,7 +91,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 25, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/extend_decorator_1.ets.autofix.json b/ets2panda/linter/test/main/extend_decorator_1.ets.autofix.json index 6f96180e67fa6209a20ab9ec6749d26b7b64f0a5..375b4f744053b85e2962fe8b392d1f6de399a9ef 100644 --- a/ets2panda/linter/test/main/extend_decorator_1.ets.autofix.json +++ b/ets2panda/linter/test/main/extend_decorator_1.ets.autofix.json @@ -179,7 +179,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -200,7 +200,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -242,7 +242,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json b/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json index c7c9c047cb79bf3fe6e17e75068d42cba906fc2c..eee42f58f0450a05faf2cd75d35139f35e77c1cd 100755 --- a/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json +++ b/ets2panda/linter/test/main/func_inferred_type_args.ets.arkts2.json @@ -294,6 +294,16 @@ "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)", "severity": "ERROR" }, + { + "line": 73, + "column": 1, + "endLine": 73, + "endColumn": 11, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, { "line": 78, "column": 37, 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 636e016aeadd253445251567c7f09fa7da3bd996..0d7b3467d126b8e6bea4fc6beeba0dce2da29187 100644 --- a/ets2panda/linter/test/main/func_inferred_type_args_2.ets +++ b/ets2panda/linter/test/main/func_inferred_type_args_2.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { AttributeUpdater } from '@kit.ArkUI'; const irreparableArr = new Array(); let repairableArr: Array = new Array(); @@ -37,7 +38,7 @@ repairableC.repairableSet = new Set(); repairableC.repairableMap = new Map(); MyClass.repairableStaticMap = new Map(); -const promise: Promise = new Promise(()=> {return ''}); +const promise: Promise = new Promise(() => { return ''; }); function testA(): Map { return new Map(); @@ -72,3 +73,24 @@ class MyClassB { return new Set(); } } + +const testMap: Map = new Map([ + ['123', 1], // my comment 1 + ['sfe', 2] // my comment 2 +]); +let a : Array = new Array(); +function foo(arr:Array) { } +foo(new Array()); +@Observed +export class AppIconCloneBadgeVm { + @Track public cloneBadgeModifier: AttributeUpdater = new AttributeUpdater(); +} +class B {} +class C {} +class A { + t:T; + constructor(t:T) { + this.t = t; + } +} +new A(new C()) 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 8332379fa7ccc19ab8c5ff0b28b5ca38417e962e..bc1cd482a41b7487c1b342d0bf71524cb06befd0 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 @@ -1,23 +1,23 @@ { "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." + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." ], "result": [ { - "line": 16, + "line": 17, "column": 7, - "endLine": 16, + "endLine": 17, "endColumn": 35, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 16, + "line": 17, "column": 24, - "endLine": 16, + "endLine": 17, "endColumn": 35, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 17, + "line": 18, "column": 36, - "endLine": 17, + "endLine": 18, "endColumn": 47, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 18, + "line": 19, "column": 17, - "endLine": 18, + "endLine": 19, "endColumn": 28, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 7, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 7, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 24, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 21, + "line": 22, "column": 44, - "endLine": 21, + "endLine": 22, "endColumn": 53, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 22, + "line": 23, "column": 17, - "endLine": 22, + "endLine": 23, "endColumn": 26, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -105,9 +105,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 3, - "endLine": 25, + "endLine": 26, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -115,9 +115,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 3, - "endLine": 25, + "endLine": 26, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -125,9 +125,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 27, - "endLine": 25, + "endLine": 26, "endColumn": 36, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -135,9 +135,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 10, - "endLine": 26, + "endLine": 27, "endColumn": 23, "problem": "StructuralIdentity", "suggest": "", @@ -145,9 +145,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 39, - "endLine": 26, + "endLine": 27, "endColumn": 48, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -155,9 +155,9 @@ "severity": "ERROR" }, { - "line": 27, + "line": 28, "column": 55, - "endLine": 27, + "endLine": 28, "endColumn": 64, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -165,9 +165,9 @@ "severity": "ERROR" }, { - "line": 28, + "line": 29, "column": 61, - "endLine": 28, + "endLine": 29, "endColumn": 70, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -175,9 +175,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 7, - "endLine": 32, + "endLine": 33, "endColumn": 35, "problem": "UnknownType", "suggest": "", @@ -185,9 +185,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 22, - "endLine": 32, + "endLine": 33, "endColumn": 35, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -195,9 +195,9 @@ "severity": "ERROR" }, { - "line": 34, + "line": 35, "column": 38, - "endLine": 34, + "endLine": 35, "endColumn": 51, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -205,9 +205,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 30, - "endLine": 35, + "endLine": 36, "endColumn": 39, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -215,9 +215,9 @@ "severity": "ERROR" }, { - "line": 36, + "line": 37, "column": 29, - "endLine": 36, + "endLine": 37, "endColumn": 38, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -225,9 +225,9 @@ "severity": "ERROR" }, { - "line": 37, + "line": 38, "column": 29, - "endLine": 37, + "endLine": 38, "endColumn": 38, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -235,9 +235,9 @@ "severity": "ERROR" }, { - "line": 38, + "line": 39, "column": 31, - "endLine": 38, + "endLine": 39, "endColumn": 40, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -245,19 +245,29 @@ "severity": "ERROR" }, { - "line": 40, + "line": 41, "column": 34, - "endLine": 40, - "endColumn": 63, + "endLine": 41, + "endColumn": 67, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, { - "line": 43, + "line": 44, + "column": 14, + "endLine": 44, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 44, "column": 10, - "endLine": 43, + "endLine": 44, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -265,9 +275,19 @@ "severity": "ERROR" }, { - "line": 47, + "line": 48, + "column": 14, + "endLine": 48, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 48, "column": 10, - "endLine": 47, + "endLine": 48, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -275,9 +295,9 @@ "severity": "ERROR" }, { - "line": 51, + "line": 52, "column": 10, - "endLine": 51, + "endLine": 52, "endColumn": 19, "problem": "StructuralIdentity", "suggest": "", @@ -285,9 +305,19 @@ "severity": "ERROR" }, { - "line": 51, + "line": 52, + "column": 14, + "endLine": 52, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 52, "column": 10, - "endLine": 51, + "endLine": 52, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -295,9 +325,9 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, "column": 10, - "endLine": 55, + "endLine": 56, "endColumn": 19, "problem": "StructuralIdentity", "suggest": "", @@ -305,9 +335,19 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, + "column": 14, + "endLine": 56, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 56, "column": 10, - "endLine": 55, + "endLine": 56, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -315,9 +355,19 @@ "severity": "ERROR" }, { - "line": 60, + "line": 61, + "column": 16, + "endLine": 61, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 61, "column": 12, - "endLine": 60, + "endLine": 61, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -325,9 +375,19 @@ "severity": "ERROR" }, { - "line": 64, + "line": 65, + "column": 16, + "endLine": 65, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 65, "column": 12, - "endLine": 64, + "endLine": 65, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -335,9 +395,9 @@ "severity": "ERROR" }, { - "line": 68, + "line": 69, "column": 12, - "endLine": 68, + "endLine": 69, "endColumn": 21, "problem": "StructuralIdentity", "suggest": "", @@ -345,9 +405,19 @@ "severity": "ERROR" }, { - "line": 68, + "line": 69, + "column": 16, + "endLine": 69, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 69, "column": 12, - "endLine": 68, + "endLine": 69, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -355,9 +425,9 @@ "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 12, - "endLine": 72, + "endLine": 73, "endColumn": 21, "problem": "StructuralIdentity", "suggest": "", @@ -365,14 +435,124 @@ "severity": "ERROR" }, { - "line": 72, + "line": 73, + "column": 16, + "endLine": 73, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 73, "column": 12, - "endLine": 72, + "endLine": 73, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" + }, + { + "line": 77, + "column": 38, + "endLine": 80, + "endColumn": 3, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 11, + "endLine": 78, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 11, + "endLine": 79, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 25, + "endLine": 81, + "endColumn": 36, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 5, + "endLine": 83, + "endColumn": 16, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 77, + "endLine": 86, + "endColumn": 93, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 2, + "endLine": 84, + "endColumn": 10, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Observed\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 4, + "endLine": 86, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Track\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 54, + "endLine": 86, + "endColumn": 69, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"CommonAttribute\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 94, + "endLine": 86, + "endColumn": 109, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"CommonAttribute\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.autofix.json index 773fea5ff8c4e90cfc4e962f87f7eb24ea4edf71..e59af03e373bd0e79d080f72f6d92e1369e02e6a 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 @@ -1,23 +1,23 @@ { "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." + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." ], "result": [ { - "line": 16, + "line": 17, "column": 7, - "endLine": 16, + "endLine": 17, "endColumn": 35, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 16, + "line": 17, "column": 24, - "endLine": 16, + "endLine": 17, "endColumn": 35, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -35,16 +35,20 @@ "severity": "ERROR" }, { - "line": 17, + "line": 18, "column": 36, - "endLine": 17, + "endLine": 18, "endColumn": 47, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 676, - "end": 687, - "replacementText": "new Array()" + "start": 732, + "end": 732, + "replacementText": "", + "line": 18, + "column": 36, + "endLine": 18, + "endColumn": 47 } ], "suggest": "", @@ -52,16 +56,20 @@ "severity": "ERROR" }, { - "line": 18, + "line": 19, "column": 17, - "endLine": 18, + "endLine": 19, "endColumn": 28, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 705, - "end": 716, - "replacementText": "new Array()" + "start": 761, + "end": 761, + "replacementText": "", + "line": 19, + "column": 17, + "endLine": 19, + "endColumn": 28 } ], "suggest": "", @@ -69,9 +77,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 7, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -79,9 +87,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 7, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -89,9 +97,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 24, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -99,16 +107,20 @@ "severity": "ERROR" }, { - "line": 21, + "line": 22, "column": 44, - "endLine": 21, + "endLine": 22, "endColumn": 53, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 796, - "end": 805, - "replacementText": "new Map()" + "start": 850, + "end": 850, + "replacementText": "", + "line": 22, + "column": 44, + "endLine": 22, + "endColumn": 53 } ], "suggest": "", @@ -116,16 +128,20 @@ "severity": "ERROR" }, { - "line": 22, + "line": 23, "column": 17, - "endLine": 22, + "endLine": 23, "endColumn": 26, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 823, - "end": 832, - "replacementText": "new Map()" + "start": 877, + "end": 877, + "replacementText": "", + "line": 23, + "column": 17, + "endLine": 23, + "endColumn": 26 } ], "suggest": "", @@ -133,9 +149,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 3, - "endLine": 25, + "endLine": 26, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -143,9 +159,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 3, - "endLine": 25, + "endLine": 26, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -153,9 +169,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 27, - "endLine": 25, + "endLine": 26, "endColumn": 36, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -163,9 +179,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 10, - "endLine": 26, + "endLine": 27, "endColumn": 23, "problem": "StructuralIdentity", "suggest": "", @@ -173,9 +189,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 39, - "endLine": 26, + "endLine": 27, "endColumn": 48, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -183,16 +199,20 @@ "severity": "ERROR" }, { - "line": 27, + "line": 28, "column": 55, - "endLine": 27, + "endLine": 28, "endColumn": 64, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 994, - "end": 1003, - "replacementText": "new Map string[]>()" + "start": 1048, + "end": 1048, + "replacementText": " string[]>", + "line": 28, + "column": 55, + "endLine": 28, + "endColumn": 64 } ], "suggest": "", @@ -200,16 +220,20 @@ "severity": "ERROR" }, { - "line": 28, + "line": 29, "column": 61, - "endLine": 28, + "endLine": 29, "endColumn": 70, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1065, - "end": 1074, - "replacementText": "new Map string[]>()" + "start": 1119, + "end": 1119, + "replacementText": " string[]>", + "line": 29, + "column": 61, + "endLine": 29, + "endColumn": 70 } ], "suggest": "", @@ -217,9 +241,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 7, - "endLine": 32, + "endLine": 33, "endColumn": 35, "problem": "UnknownType", "suggest": "", @@ -227,9 +251,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 22, - "endLine": 32, + "endLine": 33, "endColumn": 35, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -237,16 +261,20 @@ "severity": "ERROR" }, { - "line": 34, + "line": 35, "column": 38, - "endLine": 34, + "endLine": 35, "endColumn": 51, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1215, - "end": 1228, - "replacementText": "new MyClass()" + "start": 1273, + "end": 1273, + "replacementText": "", + "line": 35, + "column": 38, + "endLine": 35, + "endColumn": 51 } ], "suggest": "", @@ -254,9 +282,9 @@ "severity": "ERROR" }, { - "line": 35, + "line": 36, "column": 30, - "endLine": 35, + "endLine": 36, "endColumn": 39, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -264,16 +292,20 @@ "severity": "ERROR" }, { - "line": 36, + "line": 37, "column": 29, - "endLine": 36, + "endLine": 37, "endColumn": 38, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1298, - "end": 1307, - "replacementText": "new Set()" + "start": 1352, + "end": 1352, + "replacementText": "", + "line": 37, + "column": 29, + "endLine": 37, + "endColumn": 38 } ], "suggest": "", @@ -281,16 +313,20 @@ "severity": "ERROR" }, { - "line": 37, + "line": 38, "column": 29, - "endLine": 37, + "endLine": 38, "endColumn": 38, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1337, - "end": 1346, - "replacementText": "new Map string[]>()" + "start": 1391, + "end": 1391, + "replacementText": " string[]>", + "line": 38, + "column": 29, + "endLine": 38, + "endColumn": 38 } ], "suggest": "", @@ -298,16 +334,20 @@ "severity": "ERROR" }, { - "line": 38, + "line": 39, "column": 31, - "endLine": 38, + "endLine": 39, "endColumn": 40, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1378, - "end": 1387, - "replacementText": "new Map string[]>()" + "start": 1432, + "end": 1432, + "replacementText": " string[]>", + "line": 39, + "column": 31, + "endLine": 39, + "endColumn": 40 } ], "suggest": "", @@ -315,16 +355,20 @@ "severity": "ERROR" }, { - "line": 40, + "line": 41, "column": 34, - "endLine": 40, - "endColumn": 63, + "endLine": 41, + "endColumn": 67, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1423, - "end": 1452, - "replacementText": "new Promise(() => { return ''; })" + "start": 1481, + "end": 1481, + "replacementText": "", + "line": 41, + "column": 34, + "endLine": 41, + "endColumn": 67 } ], "suggest": "", @@ -332,16 +376,30 @@ "severity": "ERROR" }, { - "line": 43, + "line": 44, + "column": 14, + "endLine": 44, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 44, "column": 10, - "endLine": 43, + "endLine": 44, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1504, - "end": 1513, - "replacementText": "new Map()" + "start": 1562, + "end": 1562, + "replacementText": "", + "line": 44, + "column": 10, + "endLine": 44, + "endColumn": 19 } ], "suggest": "", @@ -349,16 +407,30 @@ "severity": "ERROR" }, { - "line": 47, + "line": 48, + "column": 14, + "endLine": 48, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 48, "column": 10, - "endLine": 47, + "endLine": 48, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1582, - "end": 1591, - "replacementText": "new Map()" + "start": 1640, + "end": 1640, + "replacementText": "", + "line": 48, + "column": 10, + "endLine": 48, + "endColumn": 19 } ], "suggest": "", @@ -366,9 +438,9 @@ "severity": "ERROR" }, { - "line": 51, + "line": 52, "column": 10, - "endLine": 51, + "endLine": 52, "endColumn": 19, "problem": "StructuralIdentity", "suggest": "", @@ -376,9 +448,19 @@ "severity": "ERROR" }, { - "line": 51, + "line": 52, + "column": 14, + "endLine": 52, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 52, "column": 10, - "endLine": 51, + "endLine": 52, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -386,9 +468,9 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, "column": 10, - "endLine": 55, + "endLine": 56, "endColumn": 19, "problem": "StructuralIdentity", "suggest": "", @@ -396,9 +478,19 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, + "column": 14, + "endLine": 56, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 56, "column": 10, - "endLine": 55, + "endLine": 56, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -406,16 +498,30 @@ "severity": "ERROR" }, { - "line": 60, + "line": 61, + "column": 16, + "endLine": 61, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 61, "column": 12, - "endLine": 60, + "endLine": 61, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1798, - "end": 1807, - "replacementText": "new Map()" + "start": 1856, + "end": 1856, + "replacementText": "", + "line": 61, + "column": 12, + "endLine": 61, + "endColumn": 21 } ], "suggest": "", @@ -423,16 +529,30 @@ "severity": "ERROR" }, { - "line": 64, + "line": 65, + "column": 16, + "endLine": 65, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 65, "column": 12, - "endLine": 64, + "endLine": 65, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "autofix": [ { - "start": 1873, - "end": 1882, - "replacementText": "new Map()" + "start": 1931, + "end": 1931, + "replacementText": "", + "line": 65, + "column": 12, + "endLine": 65, + "endColumn": 21 } ], "suggest": "", @@ -440,9 +560,9 @@ "severity": "ERROR" }, { - "line": 68, + "line": 69, "column": 12, - "endLine": 68, + "endLine": 69, "endColumn": 21, "problem": "StructuralIdentity", "suggest": "", @@ -450,9 +570,19 @@ "severity": "ERROR" }, { - "line": 68, + "line": 69, + "column": 16, + "endLine": 69, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 69, "column": 12, - "endLine": 68, + "endLine": 69, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -460,9 +590,9 @@ "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 12, - "endLine": 72, + "endLine": 73, "endColumn": 21, "problem": "StructuralIdentity", "suggest": "", @@ -470,14 +600,223 @@ "severity": "ERROR" }, { - "line": 72, + "line": 73, + "column": 16, + "endLine": 73, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 73, "column": 12, - "endLine": 72, + "endLine": 73, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" + }, + { + "line": 77, + "column": 38, + "endLine": 80, + "endColumn": 3, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2121, + "end": 2121, + "replacementText": "", + "line": 77, + "column": 38, + "endLine": 80, + "endColumn": 3 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 11, + "endLine": 78, + "endColumn": 12, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2134, + "end": 2135, + "replacementText": "1.0", + "line": 78, + "column": 11, + "endLine": 78, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 11, + "endLine": 79, + "endColumn": 12, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2164, + "end": 2165, + "replacementText": "2.0", + "line": 79, + "column": 11, + "endLine": 79, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 25, + "endLine": 81, + "endColumn": 36, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2220, + "end": 2220, + "replacementText": "", + "line": 81, + "column": 25, + "endLine": 81, + "endColumn": 36 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 5, + "endLine": 83, + "endColumn": 16, + "problem": "GenericCallNoTypeArgs", + "autofix": [ + { + "start": 2264, + "end": 2275, + "replacementText": "new Array()", + "line": 83, + "column": 5, + "endLine": 83, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 77, + "endLine": 86, + "endColumn": 93, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 2, + "endLine": 84, + "endColumn": 10, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Observed, Track, CommonAttribute } from '@kit.ArkUI';\n", + "line": 86, + "column": 94, + "endLine": 86, + "endColumn": 109 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Observed\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 4, + "endLine": 86, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Observed, Track, CommonAttribute } from '@kit.ArkUI';\n", + "line": 86, + "column": 94, + "endLine": 86, + "endColumn": 109 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Track\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 54, + "endLine": 86, + "endColumn": 69, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Observed, Track, CommonAttribute } from '@kit.ArkUI';\n", + "line": 86, + "column": 94, + "endLine": 86, + "endColumn": 109 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"CommonAttribute\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 94, + "endLine": 86, + "endColumn": 109, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Observed, Track, CommonAttribute } from '@kit.ArkUI';\n", + "line": 86, + "column": 94, + "endLine": 86, + "endColumn": 109 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"CommonAttribute\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/func_inferred_type_args_2.ets.json b/ets2panda/linter/test/main/func_inferred_type_args_2.ets.json index 1f00081d43be7bede54b70559d1f112d1b9b47ab..616182be4e0c7ce4752b97ba2f6e5fa0230976f9 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 @@ -15,9 +15,9 @@ ], "result": [ { - "line": 16, + "line": 17, "column": 7, - "endLine": 16, + "endLine": 17, "endColumn": 35, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 7, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 21, "column": 7, - "endLine": 20, + "endLine": 21, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 3, - "endLine": 25, + "endLine": 26, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 3, - "endLine": 25, + "endLine": 26, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 7, - "endLine": 32, + "endLine": 33, "endColumn": 35, "problem": "UnknownType", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 33, "column": 22, - "endLine": 32, + "endLine": 33, "endColumn": 35, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 51, + "line": 52, "column": 10, - "endLine": 51, + "endLine": 52, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 55, + "line": 56, "column": 10, - "endLine": 55, + "endLine": 56, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -105,9 +105,9 @@ "severity": "ERROR" }, { - "line": 68, + "line": 69, "column": 12, - "endLine": 68, + "endLine": 69, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -115,9 +115,9 @@ "severity": "ERROR" }, { - "line": 72, + "line": 73, "column": 12, - "endLine": 72, + "endLine": 73, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", 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 01a5d89f97c06ce79226ada89136f658d4d19bdb..f76d33da3742481bb93f4b6adf3f99409d9b0f05 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 @@ -13,6 +13,10 @@ * limitations under the License. */ +import { Observed, Track, CommonAttribute } from '@kit.ArkUI'; + +import { AttributeUpdater } from '@kit.ArkUI'; + const irreparableArr = new Array(); let repairableArr: Array = new Array(); repairableArr = new Array(); @@ -72,3 +76,24 @@ class MyClassB { return new Set(); } } + +const testMap: Map = new Map([ + ['123', 1.0], // my comment 1 + ['sfe', 2.0] // my comment 2 +]); +let a : Array = new Array(); +function foo(arr:Array) { } +foo(new Array()); +@Observed +export class AppIconCloneBadgeVm { + @Track public cloneBadgeModifier: AttributeUpdater = new AttributeUpdater(); +} +class B {} +class C {} +class A { + t:T; + constructor(t:T) { + this.t = t; + } +} +new A(new C()) 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 a3d92d0d965596b23b8e137b426e01275b3f7847..7926f03ac94dcdc467fc0e4a01f20384c2d1735c 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 @@ -15,9 +15,9 @@ ], "result": [ { - "line": 16, + "line": 20, "column": 7, - "endLine": 16, + "endLine": 20, "endColumn": 35, "problem": "AnyType", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 16, + "line": 20, "column": 24, - "endLine": 16, + "endLine": 20, "endColumn": 35, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -35,9 +35,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 24, "column": 7, - "endLine": 20, + "endLine": 24, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -45,9 +45,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 24, "column": 7, - "endLine": 20, + "endLine": 24, "endColumn": 33, "problem": "AnyType", "suggest": "", @@ -55,9 +55,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 24, "column": 24, - "endLine": 20, + "endLine": 24, "endColumn": 33, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -65,9 +65,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 29, "column": 3, - "endLine": 25, + "endLine": 29, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -75,9 +75,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 29, "column": 3, - "endLine": 25, + "endLine": 29, "endColumn": 37, "problem": "AnyType", "suggest": "", @@ -85,9 +85,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 29, "column": 27, - "endLine": 25, + "endLine": 29, "endColumn": 36, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -95,9 +95,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 30, "column": 10, - "endLine": 26, + "endLine": 30, "endColumn": 23, "problem": "StructuralIdentity", "suggest": "", @@ -105,9 +105,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 30, "column": 39, - "endLine": 26, + "endLine": 30, "endColumn": 48, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -115,9 +115,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 36, "column": 7, - "endLine": 32, + "endLine": 36, "endColumn": 35, "problem": "UnknownType", "suggest": "", @@ -125,9 +125,9 @@ "severity": "ERROR" }, { - "line": 32, + "line": 36, "column": 22, - "endLine": 32, + "endLine": 36, "endColumn": 35, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -135,19 +135,39 @@ "severity": "ERROR" }, { - "line": 35, + "line": 39, "column": 30, - "endLine": 35, + "endLine": 39, "endColumn": 39, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 47, + "column": 14, + "endLine": 47, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, { "line": 51, - "column": 10, + "column": 14, "endLine": 51, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 10, + "endLine": 55, "endColumn": 19, "problem": "StructuralIdentity", "suggest": "", @@ -155,9 +175,19 @@ "severity": "ERROR" }, { - "line": 51, + "line": 55, + "column": 14, + "endLine": 55, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 55, "column": 10, - "endLine": 51, + "endLine": 55, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -165,9 +195,9 @@ "severity": "ERROR" }, { - "line": 55, + "line": 59, "column": 10, - "endLine": 55, + "endLine": 59, "endColumn": 19, "problem": "StructuralIdentity", "suggest": "", @@ -175,19 +205,49 @@ "severity": "ERROR" }, { - "line": 55, + "line": 59, + "column": 14, + "endLine": 59, + "endColumn": 17, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 59, "column": 10, - "endLine": 55, + "endLine": 59, "endColumn": 19, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, + { + "line": 64, + "column": 16, + "endLine": 64, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, { "line": 68, - "column": 12, + "column": 16, "endLine": 68, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 12, + "endLine": 72, "endColumn": 21, "problem": "StructuralIdentity", "suggest": "", @@ -195,9 +255,19 @@ "severity": "ERROR" }, { - "line": 68, + "line": 72, + "column": 16, + "endLine": 72, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 72, "column": 12, - "endLine": 68, + "endLine": 72, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -205,9 +275,9 @@ "severity": "ERROR" }, { - "line": 72, + "line": 76, "column": 12, - "endLine": 72, + "endLine": 76, "endColumn": 21, "problem": "StructuralIdentity", "suggest": "", @@ -215,14 +285,34 @@ "severity": "ERROR" }, { - "line": 72, + "line": 76, + "column": 16, + "endLine": 76, + "endColumn": 19, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 76, "column": 12, - "endLine": 72, + "endLine": 76, "endColumn": 21, "problem": "GenericCallNoTypeArgs", "suggest": "", "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" + }, + { + "line": 89, + "column": 77, + "endLine": 89, + "endColumn": 93, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/global_this.ets.args.json b/ets2panda/linter/test/main/global_this.ets.args.json index a89d885810708ad03d96e3e14bb6590efd1a7547..4d93062f69db6d74420adeb506e0ca28c5580728 100644 --- a/ets2panda/linter/test/main/global_this.ets.args.json +++ b/ets2panda/linter/test/main/global_this.ets.args.json @@ -14,8 +14,6 @@ "limitations under the License." ], "mode": { - "arkts2": "", - "autofix": "--arkts-2", - "migrate": "--arkts-2" + "arkts2": "" } } diff --git a/ets2panda/linter/test/main/index_negative.ets.arkts2.json b/ets2panda/linter/test/main/index_negative.ets.arkts2.json index d1daebd5f8a021b6d2daa1afa892f0a62a28f0c9..522db19434d8ff53553079ff70b2e8ebcd6974e3 100755 --- a/ets2panda/linter/test/main/index_negative.ets.arkts2.json +++ b/ets2panda/linter/test/main/index_negative.ets.arkts2.json @@ -64,6 +64,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 17, + "column": 15, + "endLine": 17, + "endColumn": 26, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 18, "column": 5, @@ -84,6 +94,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 18, + "column": 16, + "endLine": 18, + "endColumn": 28, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 19, "column": 1, @@ -94,6 +114,36 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 1, + "endLine": 21, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 21, "column": 10, @@ -154,6 +204,26 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 28, + "column": 9, + "endLine": 28, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 21, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 32, "column": 1, @@ -184,6 +254,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 37, + "column": 1, + "endLine": 37, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 38, "column": 1, @@ -194,6 +274,26 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 38, + "column": 1, + "endLine": 38, + "endColumn": 14, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 1, + "endLine": 39, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 39, "column": 5, @@ -204,6 +304,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 40, + "column": 1, + "endLine": 40, + "endColumn": 14, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 40, "column": 5, @@ -234,6 +344,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 42, + "column": 1, + "endLine": 42, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 42, "column": 5, @@ -244,6 +364,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 44, + "column": 1, + "endLine": 44, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 44, "column": 5, @@ -254,6 +384,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 45, + "column": 1, + "endLine": 45, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 45, "column": 5, @@ -264,6 +404,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 47, + "column": 1, + "endLine": 47, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 47, "column": 5, @@ -274,6 +424,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 48, + "column": 1, + "endLine": 48, + "endColumn": 14, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 48, "column": 5, @@ -294,6 +454,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 50, + "column": 1, + "endLine": 50, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 50, "column": 5, @@ -314,6 +484,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 52, + "column": 1, + "endLine": 52, + "endColumn": 15, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 52, "column": 5, @@ -324,6 +504,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 53, + "column": 1, + "endLine": 53, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 53, "column": 5, @@ -344,6 +534,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 54, + "column": 1, + "endLine": 54, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 54, "column": 5, @@ -354,6 +554,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 56, + "column": 1, + "endLine": 56, + "endColumn": 31, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 56, "column": 6, @@ -374,6 +584,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 57, + "column": 1, + "endLine": 57, + "endColumn": 29, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 57, "column": 5, @@ -384,6 +604,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 58, + "column": 1, + "endLine": 58, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 58, "column": 5, @@ -394,6 +624,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 59, + "column": 1, + "endLine": 59, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 59, "column": 5, @@ -414,6 +654,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 60, + "column": 1, + "endLine": 60, + "endColumn": 17, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 60, "column": 5, @@ -434,6 +684,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 61, + "column": 1, + "endLine": 61, + "endColumn": 16, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 61, "column": 5, @@ -454,6 +714,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 63, + "column": 1, + "endLine": 63, + "endColumn": 31, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 63, "column": 6, @@ -464,6 +734,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 64, + "column": 1, + "endLine": 64, + "endColumn": 31, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 65, "column": 1, @@ -474,6 +754,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 65, + "column": 1, + "endLine": 65, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 65, "column": 5, @@ -494,6 +784,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 66, + "column": 1, + "endLine": 66, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 66, "column": 5, @@ -514,6 +814,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 68, + "column": 1, + "endLine": 68, + "endColumn": 31, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 68, "column": 5, @@ -524,6 +834,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 69, + "column": 1, + "endLine": 69, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 69, "column": 5, @@ -534,6 +854,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 70, "column": 5, @@ -554,6 +884,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 31, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 72, "column": 5, @@ -574,6 +914,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 73, + "column": 1, + "endLine": 73, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 73, "column": 5, @@ -724,6 +1074,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 80, + "column": 1, + "endLine": 80, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 80, "column": 5, @@ -734,6 +1094,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 81, "column": 5, @@ -754,6 +1124,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 82, + "column": 1, + "endLine": 82, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 82, "column": 5, @@ -774,6 +1154,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 83, + "column": 1, + "endLine": 83, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 83, "column": 5, @@ -784,6 +1174,16 @@ "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", "severity": "ERROR" }, + { + "line": 84, + "column": 1, + "endLine": 84, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 84, "column": 5, @@ -804,6 +1204,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 85, + "column": 1, + "endLine": 85, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 85, "column": 5, @@ -844,6 +1254,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 87, + "column": 1, + "endLine": 87, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 87, "column": 5, @@ -858,7 +1278,7 @@ "line": 88, "column": 5, "endLine": 88, - "endColumn": 7, + "endColumn": 17, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -874,11 +1294,21 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 89, + "column": 1, + "endLine": 89, + "endColumn": 18, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 89, "column": 5, "endLine": 89, - "endColumn": 7, + "endColumn": 17, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -898,7 +1328,7 @@ "line": 90, "column": 5, "endLine": 90, - "endColumn": 7, + "endColumn": 17, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -924,6 +1354,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 91, + "column": 1, + "endLine": 91, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 91, "column": 5, @@ -944,6 +1384,16 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 92, + "column": 1, + "endLine": 92, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 92, "column": 5, @@ -974,6 +1424,26 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 96, + "column": 11, + "endLine": 96, + "endColumn": 24, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 11, + "endLine": 97, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 97, "column": 15, @@ -1014,11 +1484,21 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 99, + "column": 1, + "endLine": 99, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 99, "column": 5, "endLine": 99, - "endColumn": 14, + "endColumn": 24, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -1034,11 +1514,21 @@ "rule": "The index expression must be zero or positive value.(arkts-array-index-negative)", "severity": "ERROR" }, + { + "line": 100, + "column": 1, + "endLine": 100, + "endColumn": 19, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 100, "column": 5, "endLine": 100, - "endColumn": 8, + "endColumn": 18, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", diff --git a/ets2panda/linter/test/main/interface_import_1.ets.arkts2.json b/ets2panda/linter/test/main/interface_import_1.ets.arkts2.json index 953e84542d0fa2136b8adb75eec1e5f7974fcda1..37724c0f17f7a8ed87fea2a1f31f69e778b1d2a3 100644 --- a/ets2panda/linter/test/main/interface_import_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/interface_import_1.ets.arkts2.json @@ -81,7 +81,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -151,7 +151,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -161,7 +161,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -171,7 +171,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -181,7 +181,7 @@ "endColumn": 18, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AnimatableExtend\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -191,7 +191,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -201,7 +201,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -211,7 +211,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ "endColumn": 44, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ImageFit\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/interface_import_1.ets.autofix.json b/ets2panda/linter/test/main/interface_import_1.ets.autofix.json index deacf76eb3cf7a24628c3329f028d3b5e52e9fdd..3379f754c73e584c19a419868e9d4c2e65dc1470 100644 --- a/ets2panda/linter/test/main/interface_import_1.ets.autofix.json +++ b/ets2panda/linter/test/main/interface_import_1.ets.autofix.json @@ -158,7 +158,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -179,7 +179,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -200,7 +200,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -242,7 +242,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -263,7 +263,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -284,7 +284,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -305,7 +305,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -326,7 +326,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -347,7 +347,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -368,7 +368,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AnimatableExtend\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -389,7 +389,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -410,7 +410,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -431,7 +431,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -452,7 +452,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ImageFit\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/interface_import_3.ets.arkts2.json b/ets2panda/linter/test/main/interface_import_3.ets.arkts2.json index 680b868bc155d9c6b2db73667b34a67b26b2fb8f..1f8aa52d844af08fea2af983d1e8cc01751f508e 100644 --- a/ets2panda/linter/test/main/interface_import_3.ets.arkts2.json +++ b/ets2panda/linter/test/main/interface_import_3.ets.arkts2.json @@ -41,7 +41,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/interface_import_3.ets.autofix.json b/ets2panda/linter/test/main/interface_import_3.ets.autofix.json index 8bb68631570a7b49838734f2cd9b8a92e992e78e..a149f61d6c4dfc567aa1f7b252f9afa5c6506dd0 100644 --- a/ets2panda/linter/test/main/interface_import_3.ets.autofix.json +++ b/ets2panda/linter/test/main/interface_import_3.ets.autofix.json @@ -52,7 +52,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -73,7 +73,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/interface_import_4.ets b/ets2panda/linter/test/main/interface_import_4.ets new file mode 100644 index 0000000000000000000000000000000000000000..f682328f82a92eea9dccb7b40c33e4dc1aa10b23 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@ComponentV2 +struct MyComponent { + @Local arr: Array = []; + scroller: Scroller = new Scroller(); + build() { + Column({ space: 5 }) { + List({ scroller: this.scroller, space: 5, initialIndex: 100 }) { + Repeat(this.arr) + .virtualScroll({ + onTotalCount: () => { return 1000; }, + onLazyLoading: (index: number) => { this.arr[index] = index.toString(); } + }) + .each((obj: RepeatItem) => { + ListItem() { + Row({ space: 5 }) { + Text(`${obj.index}: Item_${obj.item}`) + } + } + .height(50) + }) + } + .height('80%') + .border({ width: 1}) + Button('ScrollToIndex 500') + .onClick(() => { this.scroller.scrollToIndex(500); }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.args.json b/ets2panda/linter/test/main/interface_import_4.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..ef3938e967322a0c7551d84c7b6d280de94144c8 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.arkts2.json b/ets2panda/linter/test/main/interface_import_4.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..846e6e009e684307cfd2137459f331cc686c9ba0 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.arkts2.json @@ -0,0 +1,248 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 21, + "endLine": 22, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 46, + "endLine": 23, + "endColumn": 47, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 63, + "endLine": 23, + "endColumn": 66, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 42, + "endLine": 26, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 58, + "endLine": 27, + "endColumn": 63, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 28, + "endLine": 31, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 21, + "endLine": 35, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 24, + "endLine": 39, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 54, + "endLine": 41, + "endColumn": 57, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 13, + "endLine": 20, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 15, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 33, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 13, + "endLine": 30, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 15, + "endLine": 31, + "endColumn": 18, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 17, + "endLine": 32, + "endColumn": 21, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/interface_import_4.ets.autofix.json b/ets2panda/linter/test/main/interface_import_4.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..1ba9932fa3b85bceb411b5b196bcedc3ab64a3a7 --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.autofix.json @@ -0,0 +1,490 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 21, + "endLine": 22, + "endColumn": 22, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 751, + "end": 752, + "replacementText": "5.0", + "line": 22, + "column": 21, + "endLine": 22, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 46, + "endLine": 23, + "endColumn": 47, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 803, + "end": 804, + "replacementText": "5.0", + "line": 23, + "column": 46, + "endLine": 23, + "endColumn": 47 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 63, + "endLine": 23, + "endColumn": 66, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 820, + "end": 823, + "replacementText": "100.0", + "line": 23, + "column": 63, + "endLine": 23, + "endColumn": 66 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 42, + "endLine": 26, + "endColumn": 46, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 922, + "end": 926, + "replacementText": "1000.0", + "line": 26, + "column": 42, + "endLine": 26, + "endColumn": 46 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 58, + "endLine": 27, + "endColumn": 63, + "problem": "ArrayIndexExprType", + "autofix": [ + { + "start": 988, + "end": 993, + "replacementText": "index as int", + "line": 27, + "column": 58, + "endLine": 27, + "endColumn": 63 + } + ], + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 28, + "endLine": 31, + "endColumn": 29, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1129, + "end": 1130, + "replacementText": "5.0", + "line": 31, + "column": 28, + "endLine": 31, + "endColumn": 29 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 21, + "endLine": 35, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1241, + "end": 1243, + "replacementText": "50.0", + "line": 35, + "column": 21, + "endLine": 35, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 24, + "endLine": 39, + "endColumn": 25, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1310, + "end": 1311, + "replacementText": "1.0", + "line": 39, + "column": 24, + "endLine": 39, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 54, + "endLine": 41, + "endColumn": 57, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1401, + "end": 1404, + "replacementText": "500.0", + "line": 41, + "column": 54, + "endLine": 41, + "endColumn": 57 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 2, + "endLine": 16, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 2, + "endLine": 17, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 4, + "endLine": 19, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 13, + "endLine": 20, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 28, + "endLine": 20, + "endColumn": 36, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Scroller\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 7, + "endLine": 23, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 9, + "endLine": 24, + "endColumn": 15, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Repeat\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 23, + "endLine": 29, + "endColumn": 33, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"RepeatItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 13, + "endLine": 30, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 15, + "endLine": 31, + "endColumn": 18, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 17, + "endLine": 32, + "endColumn": 21, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI';", + "line": 40, + "column": 7, + "endLine": 40, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_name_from_value.ets.json b/ets2panda/linter/test/main/interface_import_4.ets.json similarity index 100% rename from ets2panda/linter/test/main/prop_name_from_value.ets.json rename to ets2panda/linter/test/main/interface_import_4.ets.json diff --git a/ets2panda/linter/test/main/interface_import_4.ets.migrate.ets b/ets2panda/linter/test/main/interface_import_4.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..0087934e5c49d6530cc2412f8c5ad8133d29627c --- /dev/null +++ b/ets2panda/linter/test/main/interface_import_4.ets.migrate.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Entry, ComponentV2, Local, Scroller, Column, List, Repeat, RepeatItem, ListItem, Row, Text, Button } from '@kit.ArkUI'; + +@Entry +@ComponentV2 +struct MyComponent { + @Local arr: Array = []; + scroller: Scroller = new Scroller(); + build() { + Column({ space: 5.0 }) { + List({ scroller: this.scroller, space: 5.0, initialIndex: 100.0 }) { + Repeat(this.arr) + .virtualScroll({ + onTotalCount: () => { return 1000.0; }, + onLazyLoading: (index: number) => { this.arr[index as int] = index.toString(); } + }) + .each((obj: RepeatItem) => { + ListItem() { + Row({ space: 5.0 }) { + Text(`${obj.index}: Item_${obj.item}`) + } + } + .height(50.0) + }) + } + .height('80%') + .border({ width: 1.0}) + Button('ScrollToIndex 500') + .onClick(() => { this.scroller.scrollToIndex(500.0); }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_name_from_value.ets.arkts2.json b/ets2panda/linter/test/main/interface_import_4.ets.migrate.json similarity index 75% rename from ets2panda/linter/test/main/prop_name_from_value.ets.arkts2.json rename to ets2panda/linter/test/main/interface_import_4.ets.migrate.json index 4218268d314b5d23e17b0cb47ab709da3f410059..1aecbf6f5346add2ed34ff6b04dd3052f7a8e576 100644 --- a/ets2panda/linter/test/main/prop_name_from_value.ets.arkts2.json +++ b/ets2panda/linter/test/main/interface_import_4.ets.migrate.json @@ -15,13 +15,13 @@ ], "result": [ { - "line": 23, - "column": 13, - "endLine": 23, - "endColumn": 20, - "problem": "UnsupportPropNameFromValue", + "line": 22, + "column": 28, + "endLine": 22, + "endColumn": 36, + "problem": "DynamicCtorCall", "suggest": "", - "rule": "Enum cannot get member name by member value (arkts-unsupport-prop-name-from-value)", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json index 2999205f9565c7610abab7a3471711f09e29ea9f..8d294f2636de9279c884b61f8343aa0856510011 100644 --- a/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json +++ b/ets2panda/linter/test/main/invalid_identifier.ets.arkts2.json @@ -24,6 +24,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 56, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, { "line": 18, "column": 8, @@ -784,6 +794,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 205, + "column": 12, + "endLine": 205, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 206, "column": 3, @@ -794,6 +814,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 206, + "column": 9, + "endLine": 206, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 209, "column": 11, @@ -841,7 +871,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -851,7 +881,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -861,7 +891,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -871,7 +901,7 @@ "endColumn": 22, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"RelativeContainer\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -881,7 +911,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -891,7 +921,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -901,7 +931,7 @@ "endColumn": 22, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"RelativeContainer\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -911,7 +941,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/limit_void_type.ets b/ets2panda/linter/test/main/limit_void_type.ets index d6ae5d427f0946f89ddb7962cda23e30a91be021..7cb24cf7cfb7aa299b8e290353cd57922ef97bd8 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets +++ b/ets2panda/linter/test/main/limit_void_type.ets @@ -15,48 +15,48 @@ // Example 1: Basic function -function func1(): void {} +function func1(): void { } let a: void = func1(); // Example 2: Arrow function -const func2 = (): void => {}; +const func2 = (): void => { }; let b: void = func2(); // Example 3: Class method class Demo { - method(): void {} + method(): void { } } let c: void = new Demo().method(); // Example 4: Immediately Invoked Function Expression (IIFE) -let d: void = (function(): void {})(); +let d: void = (function (): void { })(); // Example 5: Asynchronous function -async function asyncFunc(): Promise {} +async function asyncFunc(): Promise { } let e: void = await asyncFunc(); // Example 6: Function parameter function wrapper(fn: () => void) { let f: void = fn(); } // Example 7: Type assertion -function func3(): void {} +function func3(): void { } let g: void = func3() as void; // Example 8: Callback function -setTimeout((): void => {}, 1000); -let h: void = setTimeout(() => {}, 1000); +setTimeout((): void => { }, 1000); +let h: void = setTimeout(() => { }, 1000); // Example 9: Array operation -const funcArr: (() => void)[] = [() => {}]; +const funcArr: (() => void)[] = [() => { }]; let i: void = funcArr[0](); // Example 10: Object method const obj = { - action: (): void => {} + action: (): void => { } }; let j: void = obj.action(); // Example 11: Strict mode // @ts-strict -function func4(): void {} +function func4(): void { } let k: void = func4(); // Example 12: Module export -export function exportedFunc(): void {} +export function exportedFunc(): void { } let l: void = exportedFunc(); // Example 13: Generic function -function genericFunc(): void {} +function genericFunc(): void { } let m: void = genericFunc(); // Example 14: Function overloading function overloadFunc(): void; @@ -65,24 +65,24 @@ function overloadFunc(n?: number) { return n; } let n: void = overloadFunc(); // Example 15: Type alias type VoidFunc = () => void; -const aliasFunc: VoidFunc = () => {}; +const aliasFunc: VoidFunc = () => { }; let o: void = aliasFunc(); // Example 16: Interface implementation interface Task { run(): void; } class Printer implements Task { - run(): void {} + run(): void { } } let p: void = new Printer().run(); // Example 17: Optional parameter -function withParam(param?: string): void {} +function withParam(param?: string): void { } let q: void = withParam(); // Example 18: Rest parameter -function sum(...nums: number[]): void {} +function sum(...nums: number[]): void { } let r: void = sum(1, 2, 3); // Example 19: This parameter -function withThis(this: Window): void {} +function withThis(this: Window): void { } let s: void = withThis.call(window); // Example 20: Generator function function* genFunc(): Generator { @@ -90,31 +90,31 @@ function* genFunc(): Generator { } let u: void = genFunc().next().value; // Example 21: Function currying -const curry = () => (): void => {}; +const curry = () => (): void => { }; let w: void = curry()(); // Example 22: Method chaining class Chain { first(): this { return this; } - last(): void {} + last(): void { } } let x: void = new Chain().first().last(); // Example 23: Destructuring assignment -const [func] = [(): void => {}]; +const [func] = [(): void => { }]; let y: void = func(); // Example 24: Type mapping type Wrapper = { value: T }; -const wrapped: Wrapper<() => void> = { value: () => {} }; +const wrapped: Wrapper<() => void> = { value: () => { } }; let z: void = wrapped.value(); // Example 25: Conditional type type Conditional = T extends boolean ? () => void : never; -const condFunc: Conditional = () => {}; +const condFunc: Conditional = () => { }; let aa: void = condFunc(); // Example 26: Mixed type interface Mixed { (): void; prop: string; } -const mixed: Mixed = Object.assign(() => {}, { prop: "" }); +const mixed: Mixed = Object.assign(() => { }, { prop: "" }); let ab: void = mixed(); // Example 27: Recursive call function recursive(): void { @@ -123,13 +123,13 @@ function recursive(): void { let ac: void = recursive(); // Example 28: Decorator function function decorator() { - return function(target: any) {}; + return function (target: any) { }; } @decorator() -class Decorated {} +class Decorated { } let ad: void = decorator()(Decorated); -function f1(): void {} +function f1(): void { } let a1 = f1(); // type `void` is used as value @@ -145,24 +145,24 @@ a3[0] = f1(); // type `void` is used as value let a4: void = f1(); // type `void` is used as type annotation -function f2(a: void) {} // type `void` is used as type annotation +function f2(a: void) { } // type `void` is used as type annotation f2(f1()); // type `void` is used as value class A { f: void; // type `void` is used as type annotation - m(p: void) {} // type `void` is used as type annotation + m(p: void) { } // type `void` is used as type annotation constructor(a: void) { // type `void` is used as type annotation this.f = a; } } -function f3(): void | Promise {} // type `void` is not allowed in union type +function f3(): void | Promise { } // type `void` is not allowed in union type class B { - m(): void | number {} // type `void` is not allowed in union type + m(): void | number { } // type `void` is not allowed in union type } type ss = void; @@ -178,20 +178,20 @@ interface BT { } class C { - private cc?:BT; + private cc?: BT; - private d():void { + private d(): void { this.cc = { - qaq: (caller?:string):void => this.qaqq(caller) + qaq: (caller?: string): void => this.qaqq(caller) } } - private qaqq(caller?:string):void { + private qaqq(caller?: string): void { return; } } -function foo(): void {} -function bar(): void {} +function foo(): void { } +function bar(): void { } let aa = '1'; let bb = aa === '1' ? foo() : bar(); // Error @@ -199,7 +199,65 @@ let bb = aa === '1' ? foo() : bar(); // Error aa === '1' ? foo() : bar(); // No error let dd; dd = aa === '1' ? foo() : bar(); // Error -interface testB{ - u:void; // Error - fooIf():void; +interface testB { + u: void; // Error + fooIf(): void; +} + +function foo1():void{ + return foo(); // No Error +} + +function foocfe(a: number): string | void { + if (a >= 0) { + return "a >= 0"; + } +} + +function foocfe2(a: number): string | void { + if (a < 0) { + return; + } + return "a >= 0"; +} +function fooefc(): void { } +let ss: void = foo() +let t: void | number = foo() +let t2: void | number = 1; + +function greet(hour: number): string | void { + if (hour < 12) { + return; + } else if (hour < 18) { + return "Good afternoon"; + } else { + return; + } +} + +function logOrReturn(flag: boolean): string | void { + if (flag) { + return "Flag is true"; + } + console.log("Flag is false"); + return; +} + +function justLogs(): string | void { + console.log("Hello!"); +} + +function getStatus(code: number): string | void { + switch (code) { + case 1: return "OK"; + case 2: return "Warning"; + } +} + +function tryThing(): string | void { + try { + return "Worked!"; + } catch (e) { + console.error(e); + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.args.json b/ets2panda/linter/test/main/limit_void_type.ets.args.json index 948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c..571ee6bb76b0cad72a9443db47c2f9d7db474bd0 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.args.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.args.json @@ -1,19 +1,21 @@ { - "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", - "Licensed under the Apache License, Version 2.0 (the 'License');", - "you may not use this file except in compliance with the License.", - "You may obtain a copy of the License at", - "", - "http://www.apache.org/licenses/LICENSE-2.0", - "", - "Unless required by applicable law or agreed to in writing, software", - "distributed under the License is distributed on an 'AS IS' BASIS,", - "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", - "See the License for the specific language governing permissions and", - "limitations under the License." - ], - "mode": { - "arkts2": "" - } + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } } diff --git a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json index 39d24845a6e49fd2f89e45c2a5ef8279dc72e0b6..0ae2dd16e45ef992843652a9100522f7ff3387ba 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json @@ -88,7 +88,7 @@ "line": 29, "column": 15, "endLine": 29, - "endColumn": 38, + "endColumn": 40, "problem": "LimitedVoidType", "suggest": "", "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", @@ -98,7 +98,7 @@ "line": 29, "column": 16, "endLine": 29, - "endColumn": 35, + "endColumn": 37, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -156,9 +156,9 @@ }, { "line": 41, - "column": 28, + "column": 29, "endLine": 41, - "endColumn": 32, + "endColumn": 33, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -176,9 +176,9 @@ }, { "line": 42, - "column": 36, + "column": 37, "endLine": 42, - "endColumn": 40, + "endColumn": 41, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -204,6 +204,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 45, + "column": 15, + "endLine": 45, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 47, "column": 13, @@ -588,7 +598,7 @@ "line": 102, "column": 7, "endLine": 102, - "endColumn": 32, + "endColumn": 33, "problem": "DestructuringDeclaration", "suggest": "", "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)", @@ -706,9 +716,9 @@ }, { "line": 117, - "column": 46, + "column": 47, "endLine": 117, - "endColumn": 47, + "endColumn": 48, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", @@ -768,7 +778,7 @@ "line": 126, "column": 10, "endLine": 126, - "endColumn": 34, + "endColumn": 36, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -776,9 +786,9 @@ }, { "line": 126, - "column": 27, + "column": 28, "endLine": 126, - "endColumn": 30, + "endColumn": 31, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -884,6 +894,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 144, + "column": 1, + "endLine": 144, + "endColumn": 6, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 144, "column": 9, @@ -964,6 +984,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 162, "column": 16, @@ -974,6 +1004,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 165, "column": 8, @@ -984,6 +1024,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 168, + "column": 6, + "endLine": 168, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, { "line": 168, "column": 11, @@ -1066,9 +1116,309 @@ }, { "line": 203, - "column": 5, + "column": 6, "endLine": 203, - "endColumn": 9, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 29, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 38, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 212, + "column": 12, + "endLine": 212, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 39, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 11, + "endLine": 218, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 5, + "endLine": 224, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 9, + "endLine": 224, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 16, + "endLine": 224, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 12, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 24, + "endLine": 225, + "endColumn": 29, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 25, + "endLine": 226, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 40, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 229, + "column": 14, + "endLine": 229, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 231, + "column": 21, + "endLine": 231, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 47, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 31, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 35, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 44, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 251, + "column": 11, + "endLine": 251, + "endColumn": 15, + "problem": "SwitchExpression", + "suggest": "", + "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "severity": "ERROR" + }, + { + "line": 252, + "column": 10, + "endLine": 252, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 253, + "column": 10, + "endLine": 253, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 22, + "endLine": 257, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 31, + "endLine": 257, + "endColumn": 35, "problem": "LimitedVoidType", "suggest": "", "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", diff --git a/ets2panda/linter/test/main/limit_void_type.ets.autofix.json b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..34bbf47a13871d124dd6950a45a3dbc5561e2e88 --- /dev/null +++ b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json @@ -0,0 +1,2182 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 666, + "end": 683, + "replacementText": "a: undefined = ((): undefined => { func1(); return undefined; })()", + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 15, + "endLine": 19, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 8, + "endLine": 22, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 749, + "end": 766, + "replacementText": "b: undefined = ((): undefined => { func2(); return undefined; })()", + "line": 22, + "column": 8, + "endLine": 22, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 15, + "endLine": 22, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 835, + "end": 864, + "replacementText": "c: undefined = ((): undefined => { new Demo().method(); return undefined; })()", + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 15, + "endLine": 27, + "endColumn": 34, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 931, + "end": 966, + "replacementText": "d: undefined = ((): undefined => { (function (): void { })(); return undefined; })()", + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 15, + "endLine": 29, + "endColumn": 40, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 37, + "problem": "FunctionExpression", + "autofix": [ + { + "start": 942, + "end": 963, + "replacementText": "(): void => { }", + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 8, + "endLine": 32, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1054, + "end": 1081, + "replacementText": "e: undefined = ((): undefined => { await asyncFunc(); return undefined; })()", + "line": 32, + "column": 8, + "endLine": 32, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 10, + "endLine": 35, + "endColumn": 14, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1157, + "end": 1171, + "replacementText": "f: undefined = ((): undefined => { fn(); return undefined; })()", + "line": 35, + "column": 10, + "endLine": 35, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 17, + "endLine": 35, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 8, + "endLine": 39, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1235, + "end": 1260, + "replacementText": "g: undefined = ((): undefined => { func3() as void; return undefined; })()", + "line": 39, + "column": 8, + "endLine": 39, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 15, + "endLine": 39, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 29, + "endLine": 41, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1322, + "end": 1326, + "replacementText": "1000.0", + "line": 41, + "column": 29, + "endLine": 41, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1333, + "end": 1370, + "replacementText": "h: undefined = ((): undefined => { setTimeout(() => { }, 1000); return undefined; })()", + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 37, + "endLine": 42, + "endColumn": 41, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1365, + "end": 1369, + "replacementText": "1000.0", + "line": 42, + "column": 37, + "endLine": 42, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 8, + "endLine": 45, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1451, + "end": 1473, + "replacementText": "i: undefined = ((): undefined => { funcArr[0](); return undefined; })()", + "line": 45, + "column": 8, + "endLine": 45, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 15, + "endLine": 45, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 15, + "endLine": 45, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 13, + "endLine": 47, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 8, + "endLine": 50, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1551, + "end": 1573, + "replacementText": "j: undefined = ((): undefined => { obj.action(); return undefined; })()", + "line": 50, + "column": 8, + "endLine": 50, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 15, + "endLine": 50, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 8, + "endLine": 54, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1647, + "end": 1664, + "replacementText": "k: undefined = ((): undefined => { func4(); return undefined; })()", + "line": 54, + "column": 8, + "endLine": 54, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 15, + "endLine": 54, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 8, + "endLine": 57, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1740, + "end": 1764, + "replacementText": "l: undefined = ((): undefined => { exportedFunc(); return undefined; })()", + "line": 57, + "column": 8, + "endLine": 57, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 15, + "endLine": 57, + "endColumn": 29, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 8, + "endLine": 60, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1838, + "end": 1861, + "replacementText": "m: undefined = ((): undefined => { genericFunc(); return undefined; })()", + "line": 60, + "column": 8, + "endLine": 60, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 15, + "endLine": 60, + "endColumn": 28, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 15, + "endLine": 60, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 1, + "endLine": 62, + "endColumn": 31, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 1, + "endLine": 63, + "endColumn": 42, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 1, + "endLine": 64, + "endColumn": 48, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2024, + "end": 2048, + "replacementText": "n: undefined = ((): undefined => { overloadFunc(); return undefined; })()", + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 15, + "endLine": 65, + "endColumn": 29, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 8, + "endLine": 69, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2147, + "end": 2168, + "replacementText": "o: undefined = ((): undefined => { aliasFunc(); return undefined; })()", + "line": 69, + "column": 8, + "endLine": 69, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 15, + "endLine": 69, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 8, + "endLine": 77, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2300, + "end": 2329, + "replacementText": "p: undefined = ((): undefined => { new Printer().run(); return undefined; })()", + "line": 77, + "column": 8, + "endLine": 77, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 15, + "endLine": 77, + "endColumn": 34, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 8, + "endLine": 80, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2414, + "end": 2435, + "replacementText": "q: undefined = ((): undefined => { withParam(); return undefined; })()", + "line": 80, + "column": 8, + "endLine": 80, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 15, + "endLine": 80, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 8, + "endLine": 83, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2513, + "end": 2535, + "replacementText": "r: undefined = ((): undefined => { sum(1, 2, 3); return undefined; })()", + "line": 83, + "column": 8, + "endLine": 83, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 15, + "endLine": 83, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 19, + "endLine": 83, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2527, + "end": 2528, + "replacementText": "1.0", + "line": 83, + "column": 19, + "endLine": 83, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 22, + "endLine": 83, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2530, + "end": 2531, + "replacementText": "2.0", + "line": 83, + "column": 22, + "endLine": 83, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 25, + "endLine": 83, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2533, + "end": 2534, + "replacementText": "3.0", + "line": 83, + "column": 25, + "endLine": 83, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 19, + "endLine": 85, + "endColumn": 23, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 8, + "endLine": 86, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2613, + "end": 2644, + "replacementText": "s: undefined = ((): undefined => { withThis.call(window); return undefined; })()", + "line": 86, + "column": 8, + "endLine": 86, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 24, + "endLine": 86, + "endColumn": 28, + "problem": "FunctionApplyCall", + "suggest": "", + "rule": "'Function.apply', 'Function.call' are not supported (arkts-no-func-apply-call)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 90, + "endColumn": 2, + "problem": "GeneratorFunction", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 3, + "endLine": 89, + "endColumn": 8, + "problem": "YieldExpression", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 8, + "endLine": 91, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2734, + "end": 2766, + "replacementText": "u: undefined = ((): undefined => { genFunc().next().value; return undefined; })()", + "line": 91, + "column": 8, + "endLine": 91, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 15, + "endLine": 91, + "endColumn": 37, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 8, + "endLine": 94, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2842, + "end": 2861, + "replacementText": "w: undefined = ((): undefined => { curry()(); return undefined; })()", + "line": 94, + "column": 8, + "endLine": 94, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 15, + "endLine": 94, + "endColumn": 24, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 12, + "endLine": 97, + "endColumn": 16, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 8, + "endLine": 100, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2966, + "end": 3002, + "replacementText": "x: undefined = ((): undefined => { new Chain().first().last(); return undefined; })()", + "line": 100, + "column": 8, + "endLine": 100, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 15, + "endLine": 100, + "endColumn": 41, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 7, + "endLine": 102, + "endColumn": 33, + "problem": "DestructuringDeclaration", + "autofix": [ + { + "replacementText": "GeneratedDestructArray_1", + "start": 3050, + "end": 3056, + "line": 102, + "column": 7, + "endLine": 102, + "endColumn": 33 + }, + { + "replacementText": "\nconst func = GeneratedDestructArray_1[0];\n", + "start": 3077, + "end": 3077, + "line": 102, + "column": 7, + "endLine": 102, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 8, + "endLine": 103, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3082, + "end": 3098, + "replacementText": "y: undefined = ((): undefined => { func(); return undefined; })()", + "line": 103, + "column": 8, + "endLine": 103, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 15, + "endLine": 103, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 19, + "endLine": 105, + "endColumn": 20, + "problem": "ObjectTypeLiteral", + "autofix": [ + { + "start": 3128, + "end": 3159, + "replacementText": "interface Wrapper {\n value: T;\n}", + "line": 105, + "column": 19, + "endLine": 105, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 38, + "endLine": 106, + "endColumn": 39, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 8, + "endLine": 107, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3223, + "end": 3248, + "replacementText": "z: undefined = ((): undefined => { wrapped.value(); return undefined; })()", + "line": 107, + "column": 8, + "endLine": 107, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 15, + "endLine": 107, + "endColumn": 30, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 23, + "endLine": 109, + "endColumn": 61, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 9, + "endLine": 111, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3398, + "end": 3419, + "replacementText": "aa: undefined = ((): undefined => { condFunc(); return undefined; })()", + "line": 111, + "column": 9, + "endLine": 111, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 16, + "endLine": 111, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 3, + "endLine": 114, + "endColumn": 12, + "problem": "CallSignature", + "suggest": "", + "rule": "Use \"class\" instead of a type with call signature (arkts-no-call-signatures)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 29, + "endLine": 117, + "endColumn": 35, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 47, + "endLine": 117, + "endColumn": 48, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 9, + "endLine": 118, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3560, + "end": 3578, + "replacementText": "ab: undefined = ((): undefined => { mixed(); return undefined; })()", + "line": 118, + "column": 9, + "endLine": 118, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 16, + "endLine": 118, + "endColumn": 23, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 10, + "endLine": 121, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 9, + "endLine": 123, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3667, + "end": 3689, + "replacementText": "ac: undefined = ((): undefined => { recursive(); return undefined; })()", + "line": 123, + "column": 9, + "endLine": 123, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 16, + "endLine": 123, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 10, + "endLine": 126, + "endColumn": 36, + "problem": "FunctionExpression", + "autofix": [ + { + "start": 3757, + "end": 3783, + "replacementText": "(target: any) => { }", + "line": 126, + "column": 10, + "endLine": 126, + "endColumn": 36 + } + ], + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 28, + "endLine": 126, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 1, + "endLine": 128, + "endColumn": 13, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 9, + "endLine": 130, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3824, + "end": 3857, + "replacementText": "ad: undefined = ((): undefined => { decorator()(Decorated); return undefined; })()", + "line": 130, + "column": 9, + "endLine": 130, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 16, + "endLine": 130, + "endColumn": 38, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 28, + "endLine": 130, + "endColumn": 37, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 10, + "endLine": 134, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 6, + "endLine": 136, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 9, + "endLine": 138, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3981, + "end": 3989, + "replacementText": "a2: undefined = undefined", + "line": 138, + "column": 9, + "endLine": 138, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 9, + "endLine": 140, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 19, + "endLine": 140, + "endColumn": 23, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 7, + "endLine": 142, + "endColumn": 11, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 1, + "endLine": 144, + "endColumn": 6, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 9, + "endLine": 144, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 9, + "endLine": 146, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4199, + "end": 4214, + "replacementText": "a4: undefined = ((): undefined => { f1(); return undefined; })()", + "line": 146, + "column": 9, + "endLine": 146, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 16, + "endLine": 146, + "endColumn": 20, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 16, + "endLine": 148, + "endColumn": 20, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4271, + "end": 4278, + "replacementText": "a: undefined", + "line": 148, + "column": 16, + "endLine": 148, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 4, + "endLine": 150, + "endColumn": 8, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 153, + "column": 6, + "endLine": 153, + "endColumn": 10, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4382, + "end": 4390, + "replacementText": "f: undefined = undefined;", + "line": 153, + "column": 6, + "endLine": 153, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 155, + "column": 8, + "endLine": 155, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4438, + "end": 4445, + "replacementText": "p: undefined", + "line": 155, + "column": 8, + "endLine": 155, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 18, + "endLine": 157, + "endColumn": 22, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4508, + "end": 4515, + "replacementText": "a: undefined", + "line": 157, + "column": 18, + "endLine": 157, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4599, + "end": 4619, + "replacementText": "undefined | Promise", + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36 + }, + { + "start": 4622, + "end": 4622, + "replacementText": "\nreturn undefined;\n", + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 20, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4686, + "end": 4699, + "replacementText": "undefined | number", + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21 + }, + { + "start": 4702, + "end": 4702, + "replacementText": "\nreturn undefined;\n", + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 12, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 168, + "column": 6, + "endLine": 168, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 168, + "column": 11, + "endLine": 168, + "endColumn": 15, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 12, + "endLine": 169, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 174, + "column": 22, + "endLine": 174, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 197, + "column": 23, + "endLine": 197, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 197, + "column": 31, + "endLine": 197, + "endColumn": 36, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 200, + "column": 5, + "endLine": 200, + "endColumn": 7, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 201, + "column": 19, + "endLine": 201, + "endColumn": 24, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 201, + "column": 27, + "endLine": 201, + "endColumn": 32, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 203, + "column": 6, + "endLine": 203, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 29, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5432, + "end": 5445, + "replacementText": "string | undefined", + "line": 211, + "column": 29, + "endLine": 211, + "endColumn": 42 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 38, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 212, + "column": 12, + "endLine": 212, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5459, + "end": 5460, + "replacementText": "0.0", + "line": 212, + "column": 12, + "endLine": 212, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5521, + "end": 5534, + "replacementText": "string | undefined", + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43 + }, + { + "start": 5556, + "end": 5563, + "replacementText": "return undefined;", + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 39, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 11, + "endLine": 218, + "endColumn": 12, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5547, + "end": 5548, + "replacementText": "0.0", + "line": 218, + "column": 11, + "endLine": 218, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 5, + "endLine": 224, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 9, + "endLine": 224, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5621, + "end": 5637, + "replacementText": "ss: undefined = ((): undefined => { foo(); return undefined; })()", + "line": 224, + "column": 9, + "endLine": 224, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 16, + "endLine": 224, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 21, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5642, + "end": 5666, + "replacementText": "t: undefined | number = ((): undefined | number => { foo(); return undefined; })()", + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 12, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 24, + "endLine": 225, + "endColumn": 29, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 22, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5671, + "end": 5692, + "replacementText": "t2: undefined | number = ((): undefined | number => { 1; return undefined; })()", + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 25, + "endLine": 226, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5691, + "end": 5692, + "replacementText": "1.0", + "line": 226, + "column": 25, + "endLine": 226, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5725, + "end": 5738, + "replacementText": "string | undefined", + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44 + }, + { + "start": 5764, + "end": 5771, + "replacementText": "return undefined;", + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44 + }, + { + "start": 5842, + "end": 5849, + "replacementText": "return undefined;", + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 40, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 229, + "column": 14, + "endLine": 229, + "endColumn": 16, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5754, + "end": 5756, + "replacementText": "12.0", + "line": 229, + "column": 14, + "endLine": 229, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 231, + "column": 21, + "endLine": 231, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5792, + "end": 5794, + "replacementText": "18.0", + "line": 231, + "column": 21, + "endLine": 231, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5894, + "end": 5907, + "replacementText": "string | undefined", + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51 + }, + { + "start": 5989, + "end": 5996, + "replacementText": "return undefined;", + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 47, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 6021, + "end": 6034, + "replacementText": "string | undefined", + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35 + }, + { + "start": 6062, + "end": 6062, + "replacementText": "\nreturn undefined;\n", + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 31, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 35, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 6099, + "end": 6112, + "replacementText": "string | undefined", + "line": 250, + "column": 35, + "endLine": 250, + "endColumn": 48 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 44, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 251, + "column": 11, + "endLine": 251, + "endColumn": 15, + "problem": "SwitchExpression", + "suggest": "", + "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "severity": "ERROR" + }, + { + "line": 252, + "column": 10, + "endLine": 252, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 6142, + "end": 6143, + "replacementText": "1.0", + "line": 252, + "column": 10, + "endLine": 252, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 253, + "column": 10, + "endLine": 253, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 6167, + "end": 6168, + "replacementText": "2.0", + "line": 253, + "column": 10, + "endLine": 253, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 22, + "endLine": 257, + "endColumn": 35, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 6216, + "end": 6229, + "replacementText": "string | undefined", + "line": 257, + "column": 22, + "endLine": 257, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 31, + "endLine": 257, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.json b/ets2panda/linter/test/main/limit_void_type.ets.json index c23430e5d2f182b83a08ba6b9c9c8445030b3948..1e0934e13b4d8af69357c031cfc4004d958a4efb 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.json @@ -18,7 +18,7 @@ "line": 29, "column": 16, "endLine": 29, - "endColumn": 35, + "endColumn": 37, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -88,7 +88,7 @@ "line": 102, "column": 7, "endLine": 102, - "endColumn": 32, + "endColumn": 33, "problem": "DestructuringDeclaration", "suggest": "", "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)", @@ -138,7 +138,7 @@ "line": 117, "column": 22, "endLine": 117, - "endColumn": 59, + "endColumn": 60, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", @@ -146,9 +146,9 @@ }, { "line": 117, - "column": 46, + "column": 47, "endLine": 117, - "endColumn": 47, + "endColumn": 48, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", @@ -158,7 +158,7 @@ "line": 126, "column": 10, "endLine": 126, - "endColumn": 34, + "endColumn": 36, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -166,9 +166,9 @@ }, { "line": 126, - "column": 27, + "column": 28, "endLine": 126, - "endColumn": 30, + "endColumn": 31, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -184,6 +184,16 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "WARNING" }, + { + "line": 168, + "column": 6, + "endLine": 168, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, { "line": 200, "column": 5, @@ -193,6 +203,16 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 224, + "column": 5, + "endLine": 224, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets b/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..8873cd3602a4a575d3975580afa61e9e65bab695 --- /dev/null +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets @@ -0,0 +1,273 @@ +/* + * 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. + */ + + +// Example 1: Basic function +function func1(): void { } +let a: undefined = ((): undefined => { func1(); return undefined; })(); +// Example 2: Arrow function +const func2 = (): void => { }; +let b: undefined = ((): undefined => { func2(); return undefined; })(); +// Example 3: Class method +class Demo { + method(): void { } +} +let c: undefined = ((): undefined => { new Demo().method(); return undefined; })(); +// Example 4: Immediately Invoked Function Expression (IIFE) +let d: undefined = ((): undefined => { ((): void => { })(); return undefined; })(); +// Example 5: Asynchronous function +async function asyncFunc(): Promise { } +let e: undefined = ((): undefined => { await asyncFunc(); return undefined; })(); +// Example 6: Function parameter +function wrapper(fn: () => void) { + let f: undefined = ((): undefined => { fn(); return undefined; })(); +} +// Example 7: Type assertion +function func3(): void { } +let g: undefined = ((): undefined => { func3() as void; return undefined; })(); +// Example 8: Callback function +setTimeout((): void => { }, 1000.0); +let h: undefined = ((): undefined => { setTimeout(() => { }, 1000.0); return undefined; })(); +// Example 9: Array operation +const funcArr: (() => void)[] = [() => { }]; +let i: undefined = ((): undefined => { funcArr[0](); return undefined; })(); +// Example 10: Object method +const obj = { + action: (): void => { } +}; +let j: undefined = ((): undefined => { obj.action(); return undefined; })(); +// Example 11: Strict mode +// @ts-strict +function func4(): void { } +let k: undefined = ((): undefined => { func4(); return undefined; })(); +// Example 12: Module export +export function exportedFunc(): void { } +let l: undefined = ((): undefined => { exportedFunc(); return undefined; })(); +// Example 13: Generic function +function genericFunc(): void { } +let m: undefined = ((): undefined => { genericFunc(); return undefined; })(); +// Example 14: Function overloading +function overloadFunc(): void; +function overloadFunc(n: number): number; +function overloadFunc(n?: number) { return n; } +let n: undefined = ((): undefined => { overloadFunc(); return undefined; })(); +// Example 15: Type alias +type VoidFunc = () => void; +const aliasFunc: VoidFunc = () => { }; +let o: undefined = ((): undefined => { aliasFunc(); return undefined; })(); +// Example 16: Interface implementation +interface Task { + run(): void; +} +class Printer implements Task { + run(): void { } +} +let p: undefined = ((): undefined => { new Printer().run(); return undefined; })(); +// Example 17: Optional parameter +function withParam(param?: string): void { } +let q: undefined = ((): undefined => { withParam(); return undefined; })(); +// Example 18: Rest parameter +function sum(...nums: number[]): void { } +let r: undefined = ((): undefined => { sum(1.0, 2.0, 3.0); return undefined; })(); +// Example 19: This parameter +function withThis(this: Window): void { } +let s: undefined = ((): undefined => { withThis.call(window); return undefined; })(); +// Example 20: Generator function +function* genFunc(): Generator { + yield; +} +let u: undefined = ((): undefined => { genFunc().next().value; return undefined; })(); +// Example 21: Function currying +const curry = () => (): void => { }; +let w: undefined = ((): undefined => { curry()(); return undefined; })(); +// Example 22: Method chaining +class Chain { + first(): this { return this; } + last(): void { } +} +let x: undefined = ((): undefined => { new Chain().first().last(); return undefined; })(); +// Example 23: Destructuring assignment +const GeneratedDestructArray_1 = [(): void => { }]; +const func = GeneratedDestructArray_1[0]; + +let y: undefined = ((): undefined => { func(); return undefined; })(); +// Example 24: Type mapping +interface Wrapper { + value: T; +} +const wrapped: Wrapper<() => void> = { value: () => { } }; +let z: undefined = ((): undefined => { wrapped.value(); return undefined; })(); +// Example 25: Conditional type +type Conditional = T extends boolean ? () => void : never; +const condFunc: Conditional = () => { }; +let aa: undefined = ((): undefined => { condFunc(); return undefined; })(); +// Example 26: Mixed type +interface Mixed { + (): void; + prop: string; +} +const mixed: Mixed = Object.assign(() => { }, { prop: "" }); +let ab: undefined = ((): undefined => { mixed(); return undefined; })(); +// Example 27: Recursive call +function recursive(): void { + return recursive(); +} +let ac: undefined = ((): undefined => { recursive(); return undefined; })(); +// Example 28: Decorator function +function decorator() { + return (target: any) => { }; +} +@decorator() +class Decorated { } +let ad: undefined = ((): undefined => { decorator()(Decorated); return undefined; })(); + +function f1(): void { } + +let a1 = f1(); // type `void` is used as value + +a1 = f1(); // type `void` is used as value + +let a2: undefined = undefined; // type `void` is used as type annotation + +let a3: void[] = [f1()]; // type `void` is used as type annotation + +a3 = [f1()]; // type `void` is used as value + +a3[0] = f1(); // type `void` is used as value + +let a4: undefined = ((): undefined => { f1(); return undefined; })(); // type `void` is used as type annotation + +function f2(a: undefined) { } // type `void` is used as type annotation + +f2(f1()); // type `void` is used as value + +class A { + f: undefined = undefined; // type `void` is used as type annotation + + m(p: undefined) { } // type `void` is used as type annotation + + constructor(a: undefined) { // type `void` is used as type annotation + this.f = a; + } +} + +function f3(): undefined | Promise { +return undefined; +} // type `void` is not allowed in union type + +class B { + m(): undefined | number { +return undefined; +} // type `void` is not allowed in union type +} + +type ss = void; +let sspar: ss; + +type ff = string; +let ffpar: ff; + +let sread: readonly [void] = [undefined]; + +interface BT { + qaq: Function; +} + +class C { + private cc?: BT; + + private d(): void { + this.cc = { + qaq: (caller?: string): void => this.qaqq(caller) + } + } + private qaqq(caller?: string): void { + return; + } +} + +function foo(): void { } +function bar(): void { } + +let aa = '1'; +let bb = aa === '1' ? foo() : bar(); // Error + +aa === '1' ? foo() : bar(); // No error +let dd; +dd = aa === '1' ? foo() : bar(); // Error +interface testB { + u: void; // Error + fooIf(): void; +} + +function foo1():void{ + return foo(); // No Error +} + +function foocfe(a: number): string | undefined { + if (a >= 0.0) { + return "a >= 0"; + } +} + +function foocfe2(a: number): string | undefined { + if (a < 0.0) { + return undefined; + } + return "a >= 0"; +} +function fooefc(): void { } +let ss: undefined = ((): undefined => { foo(); return undefined; })() +let t: undefined | number = ((): undefined | number => { foo(); return undefined; })() +let t2: undefined | number = ((): undefined | number => { 1.0; return undefined; })(); + +function greet(hour: number): string | undefined { + if (hour < 12.0) { + return undefined; + } else if (hour < 18.0) { + return "Good afternoon"; + } else { + return undefined; + } +} + +function logOrReturn(flag: boolean): string | undefined { + if (flag) { + return "Flag is true"; + } + console.log("Flag is false"); + return undefined; +} + +function justLogs(): string | undefined { + console.log("Hello!"); + +return undefined; +} + +function getStatus(code: number): string | undefined { + switch (code) { + case 1.0: return "OK"; + case 2.0: return "Warning"; + } +} + +function tryThing(): string | undefined { + try { + return "Worked!"; + } catch (e) { + console.error(e); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.migrate.json b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..ca74c325590ed20960e5e8f19fa66c59bffd5dbd --- /dev/null +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json @@ -0,0 +1,468 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 39, + "column": 40, + "endLine": 39, + "endColumn": 47, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 40, + "endLine": 45, + "endColumn": 50, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 13, + "endLine": 47, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 40, + "endLine": 60, + "endColumn": 53, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 1, + "endLine": 62, + "endColumn": 31, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 1, + "endLine": 63, + "endColumn": 42, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 1, + "endLine": 64, + "endColumn": 48, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 19, + "endLine": 85, + "endColumn": 23, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 49, + "endLine": 86, + "endColumn": 53, + "problem": "FunctionApplyCall", + "suggest": "", + "rule": "'Function.apply', 'Function.call' are not supported (arkts-no-func-apply-call)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 90, + "endColumn": 2, + "problem": "GeneratorFunction", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 3, + "endLine": 89, + "endColumn": 8, + "problem": "YieldExpression", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 40, + "endLine": 91, + "endColumn": 62, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 12, + "endLine": 97, + "endColumn": 16, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 14, + "endLine": 103, + "endColumn": 41, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 23, + "endLine": 113, + "endColumn": 61, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 3, + "endLine": 118, + "endColumn": 12, + "problem": "CallSignature", + "suggest": "", + "rule": "Use \"class\" instead of a type with call signature (arkts-no-call-signatures)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 29, + "endLine": 121, + "endColumn": 35, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 47, + "endLine": 121, + "endColumn": 48, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 10, + "endLine": 125, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 19, + "endLine": 130, + "endColumn": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 1, + "endLine": 132, + "endColumn": 13, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 53, + "endLine": 134, + "endColumn": 62, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 10, + "endLine": 138, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 6, + "endLine": 140, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 9, + "endLine": 144, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 19, + "endLine": 144, + "endColumn": 23, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 7, + "endLine": 146, + "endColumn": 11, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 1, + "endLine": 148, + "endColumn": 6, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 9, + "endLine": 148, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 4, + "endLine": 154, + "endColumn": 8, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 6, + "endLine": 176, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 11, + "endLine": 176, + "endColumn": 15, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 177, + "column": 12, + "endLine": 177, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 182, + "column": 22, + "endLine": 182, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 205, + "column": 23, + "endLine": 205, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 205, + "column": 31, + "endLine": 205, + "endColumn": 36, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 208, + "column": 5, + "endLine": 208, + "endColumn": 7, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 209, + "column": 19, + "endLine": 209, + "endColumn": 24, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 209, + "column": 27, + "endLine": 209, + "endColumn": 32, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 6, + "endLine": 211, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 232, + "column": 5, + "endLine": 232, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 261, + "column": 11, + "endLine": 261, + "endColumn": 15, + "problem": "SwitchExpression", + "suggest": "", + "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "severity": "ERROR" + }, + { + "line": 219, + "column": 29, + "endLine": 219, + "endColumn": 47, + "problem": "StrictDiagnostic", + "suggest": "Not all code paths return a value.", + "rule": "Not all code paths return a value.", + "severity": "ERROR" + }, + { + "line": 260, + "column": 35, + "endLine": 260, + "endColumn": 53, + "problem": "StrictDiagnostic", + "suggest": "Not all code paths return a value.", + "rule": "Not all code paths return a value.", + "severity": "ERROR" + }, + { + "line": 267, + "column": 22, + "endLine": 267, + "endColumn": 40, + "problem": "StrictDiagnostic", + "suggest": "Not all code paths return a value.", + "rule": "Not all code paths return a value.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json b/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json index affb940597e111dc0e82345f4353752bafc14639..e7bcfd0d2d6ae20f818ec874cc5ce5345d993f87 100644 --- a/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json +++ b/ets2panda/linter/test/main/limited_stdlib_api.ets.arkts2.json @@ -354,6 +354,16 @@ "rule": "Using \"Object.getOwnPropertyNames\" is not allowed in this API (arkts-builtin-object-getOwnPropertyNames))", "severity": "ERROR" }, + { + "line": 85, + "column": 1, + "endLine": 85, + "endColumn": 51, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 85, "column": 9, @@ -364,6 +374,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 86, + "column": 1, + "endLine": 86, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 86, "column": 9, @@ -384,6 +404,16 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "ERROR" }, + { + "line": 87, + "column": 1, + "endLine": 87, + "endColumn": 36, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 87, "column": 9, @@ -404,6 +434,16 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 88, + "column": 1, + "endLine": 88, + "endColumn": 34, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 88, "column": 9, @@ -414,6 +454,26 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 89, + "column": 1, + "endLine": 89, + "endColumn": 32, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 1, + "endLine": 90, + "endColumn": 53, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 90, "column": 9, @@ -424,6 +484,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 91, + "column": 1, + "endLine": 91, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 91, "column": 9, @@ -434,6 +504,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 92, + "column": 1, + "endLine": 92, + "endColumn": 25, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 92, "column": 9, @@ -444,6 +524,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 93, + "column": 1, + "endLine": 93, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 93, "column": 9, @@ -454,6 +544,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 94, + "column": 1, + "endLine": 94, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 94, "column": 9, @@ -464,6 +564,66 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 95, + "column": 1, + "endLine": 95, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 1, + "endLine": 96, + "endColumn": 46, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 1, + "endLine": 97, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 1, + "endLine": 98, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, + "endColumn": 38, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 1, + "endLine": 100, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 100, "column": 27, @@ -474,6 +634,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 101, + "column": 1, + "endLine": 101, + "endColumn": 29, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 101, "column": 19, diff --git a/ets2panda/linter/test/main/limited_stdlib_api.ets.json b/ets2panda/linter/test/main/limited_stdlib_api.ets.json index 0b436b2d76124a34bd7ba9709100409e382d9762..75f3d7b10e9b7ff3f3b2577f5761e7c4a0b426f1 100644 --- a/ets2panda/linter/test/main/limited_stdlib_api.ets.json +++ b/ets2panda/linter/test/main/limited_stdlib_api.ets.json @@ -274,6 +274,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 85, + "column": 1, + "endLine": 85, + "endColumn": 51, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 86, "column": 1, @@ -284,6 +294,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 86, + "column": 1, + "endLine": 86, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 86, "column": 32, @@ -304,6 +324,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 87, + "column": 1, + "endLine": 87, + "endColumn": 36, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 87, "column": 32, @@ -324,6 +354,26 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 88, + "column": 1, + "endLine": 88, + "endColumn": 34, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 1, + "endLine": 89, + "endColumn": 32, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 90, "column": 1, @@ -334,6 +384,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 90, + "column": 1, + "endLine": 90, + "endColumn": 53, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 91, "column": 1, @@ -344,6 +404,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 91, + "column": 1, + "endLine": 91, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 92, "column": 1, @@ -354,6 +424,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 92, + "column": 1, + "endLine": 92, + "endColumn": 25, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 93, "column": 1, @@ -364,6 +444,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 93, + "column": 1, + "endLine": 93, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 94, "column": 1, @@ -374,6 +464,86 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 94, + "column": 1, + "endLine": 94, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 1, + "endLine": 95, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 1, + "endLine": 96, + "endColumn": 46, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 1, + "endLine": 97, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 1, + "endLine": 98, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, + "endColumn": 38, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 1, + "endLine": 100, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 1, + "endLine": 101, + "endColumn": 29, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 104, "column": 32, diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets b/ets2panda/linter/test/main/literals_as_prop_names.ets index c9947181022ed196981fdc51a7673894bcd1d8e3..114339394cb2a8634ac97a7594c104b8c7bd5920 100755 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets @@ -128,11 +128,23 @@ class A{ let a:A = { "age": 30} -class B{ +class B { public 'age': number = 1 // error in arkts2 } let obj11: Record = { -['value']: 1, // 误扫 -'value2': 1 // ok -} \ No newline at end of file + ['value']: 1, // Error in arkts 2.0 + 'value2': 1 // ok +} + +class CompPropClass { + ['CompProp'] = 1; // Error in arkts 2.0 + [2] = 'CompProp2'; // Error in arkts 2.0 + [LiteralAsPropertyNameEnum.One] = 3; // Error in arkts 2.0 +} + +let compPropObj = { + ['CompProp']: 1, // Error in arkts 2.0 + [2]: 'CompProp2', // Error in arkts 2.0 + [LiteralAsPropertyNameEnum.One]: 3 // Error in arkts 2.0 +}; \ No newline at end of file diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json old mode 100755 new mode 100644 index 286fd756ff7265880cbb18d4dfc3e7848bae06e8..f6d45915a089df0fd53dfbac9eddc9b815b4f4ec --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.arkts2.json @@ -1,6 +1,6 @@ { "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Copyright (c) 2024-2025 Huawei Device Co., Ltd.", "Licensed under the Apache License, Version 2.0 (the 'License');", "you may not use this file except in compliance with the License.", "You may obtain a copy of the License at", @@ -274,6 +274,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 84, + "column": 12, + "endLine": 84, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, { "line": 84, "column": 36, @@ -294,6 +304,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 86, + "column": 1, + "endLine": 86, + "endColumn": 33, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 88, + "endColumn": 40, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 92, "column": 4, @@ -304,6 +334,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 92, + "column": 9, + "endLine": 92, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 97, "column": 3, @@ -314,6 +354,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 97, + "column": 10, + "endLine": 97, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 98, "column": 3, @@ -324,6 +374,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 98, + "column": 13, + "endLine": 98, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 102, "column": 3, @@ -334,6 +394,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 102, + "column": 10, + "endLine": 102, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 103, "column": 3, @@ -344,6 +414,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 103, + "column": 13, + "endLine": 103, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 105, "column": 5, @@ -354,6 +434,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 105, + "column": 14, + "endLine": 105, + "endColumn": 31, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 106, "column": 5, @@ -364,6 +454,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 106, + "column": 15, + "endLine": 106, + "endColumn": 35, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 109, "column": 1, @@ -374,6 +474,16 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 109, + "column": 8, + "endLine": 109, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 112, "column": 1, @@ -384,6 +494,26 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 112, + "column": 9, + "endLine": 112, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 18, + "endLine": 118, + "endColumn": 35, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 125, "column": 22, @@ -434,11 +564,31 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 135, + "column": 37, + "endLine": 135, + "endColumn": 38, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, { "line": 136, - "column": 12, + "column": 3, "endLine": 136, - "endColumn": 13, + "endColumn": 12, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 14, + "endLine": 136, + "endColumn": 15, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -446,9 +596,139 @@ }, { "line": 137, - "column": 11, + "column": 13, "endLine": 137, - "endColumn": 12, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 141, + "column": 3, + "endLine": 141, + "endColumn": 15, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 141, + "column": 18, + "endLine": 141, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 3, + "endLine": 142, + "endColumn": 6, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 4, + "endLine": 142, + "endColumn": 5, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 143, + "column": 3, + "endLine": 143, + "endColumn": 34, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 143, + "column": 37, + "endLine": 143, + "endColumn": 38, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 19, + "endLine": 146, + "endColumn": 20, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 147, + "column": 3, + "endLine": 147, + "endColumn": 15, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 147, + "column": 17, + "endLine": 147, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 3, + "endLine": 148, + "endColumn": 6, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 4, + "endLine": 148, + "endColumn": 5, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 3, + "endLine": 149, + "endColumn": 34, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 36, + "endLine": 149, + "endColumn": 37, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -461,7 +741,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -471,7 +751,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json index 282458e4e5bf09a939b7369e09cc839049e7466c..c006698019bc5041bb6aae921ef4c6209df8d26e 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json @@ -1,6 +1,6 @@ { "copyright": [ - "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Copyright (c) 2024-2025 Huawei Device Co., Ltd.", "Licensed under the Apache License, Version 2.0 (the 'License');", "you may not use this file except in compliance with the License.", "You may obtain a copy of the License at", @@ -656,6 +656,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 84, + "column": 12, + "endLine": 84, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, { "line": 84, "column": 36, @@ -687,6 +697,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 86, + "column": 1, + "endLine": 86, + "endColumn": 33, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 88, + "endColumn": 40, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 92, "column": 4, @@ -708,6 +738,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 92, + "column": 9, + "endLine": 92, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1996, + "end": 1997, + "replacementText": "1.0", + "line": 92, + "column": 9, + "endLine": 92, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 97, "column": 3, @@ -729,6 +780,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 97, + "column": 10, + "endLine": 97, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2040, + "end": 2041, + "replacementText": "1.0", + "line": 97, + "column": 10, + "endLine": 97, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 98, "column": 3, @@ -750,6 +822,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 98, + "column": 13, + "endLine": 98, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2055, + "end": 2056, + "replacementText": "1.0", + "line": 98, + "column": 13, + "endLine": 98, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 102, "column": 3, @@ -780,6 +873,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 102, + "column": 10, + "endLine": 102, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2095, + "end": 2096, + "replacementText": "1.0", + "line": 102, + "column": 10, + "endLine": 102, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 103, "column": 3, @@ -810,6 +924,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 103, + "column": 13, + "endLine": 103, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2110, + "end": 2111, + "replacementText": "1.0", + "line": 103, + "column": 13, + "endLine": 103, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 105, "column": 5, @@ -831,6 +966,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 105, + "column": 14, + "endLine": 105, + "endColumn": 31, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 106, "column": 5, @@ -852,6 +997,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 106, + "column": 15, + "endLine": 106, + "endColumn": 35, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 109, "column": 1, @@ -882,6 +1037,27 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 109, + "column": 8, + "endLine": 109, + "endColumn": 9, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2214, + "end": 2215, + "replacementText": "1.0", + "line": 109, + "column": 8, + "endLine": 109, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 112, "column": 1, @@ -903,6 +1079,37 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 112, + "column": 9, + "endLine": 112, + "endColumn": 10, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2252, + "end": 2253, + "replacementText": "1.0", + "line": 112, + "column": 9, + "endLine": 112, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 18, + "endLine": 118, + "endColumn": 35, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 125, "column": 22, @@ -975,8 +1182,8 @@ "autofix": [ { "replacementText": "age", - "start": 2465, - "end": 2470, + "start": 2466, + "end": 2471, "line": 132, "column": 10, "endLine": 132, @@ -995,8 +1202,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2481, - "end": 2482, + "start": 2482, + "end": 2483, "replacementText": "1.0", "line": 132, "column": 26, @@ -1008,21 +1215,41 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 135, + "column": 37, + "endLine": 135, + "endColumn": 38, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, { "line": 136, - "column": 12, + "column": 3, "endLine": 136, - "endColumn": 13, + "endColumn": 12, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 14, + "endLine": 136, + "endColumn": 15, "problem": "NumericSemantics", "autofix": [ { - "start": 2554, - "end": 2555, + "start": 2557, + "end": 2558, "replacementText": "1.0", "line": 136, - "column": 12, + "column": 14, "endLine": 136, - "endColumn": 13 + "endColumn": 15 } ], "suggest": "", @@ -1031,19 +1258,215 @@ }, { "line": 137, - "column": 11, + "column": 13, "endLine": 137, - "endColumn": 12, + "endColumn": 14, "problem": "NumericSemantics", "autofix": [ { - "start": 2573, - "end": 2574, + "start": 2594, + "end": 2595, "replacementText": "1.0", "line": 137, - "column": 11, + "column": 13, "endLine": 137, - "endColumn": 12 + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 141, + "column": 3, + "endLine": 141, + "endColumn": 15, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 141, + "column": 18, + "endLine": 141, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2644, + "end": 2645, + "replacementText": "1.0", + "line": 141, + "column": 18, + "endLine": 141, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 3, + "endLine": 142, + "endColumn": 6, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 4, + "endLine": 142, + "endColumn": 5, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2672, + "end": 2673, + "replacementText": "2.0", + "line": 142, + "column": 4, + "endLine": 142, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 143, + "column": 3, + "endLine": 143, + "endColumn": 34, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 143, + "column": 37, + "endLine": 143, + "endColumn": 38, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2748, + "end": 2749, + "replacementText": "3.0", + "line": 143, + "column": 37, + "endLine": 143, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 19, + "endLine": 146, + "endColumn": 20, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 147, + "column": 3, + "endLine": 147, + "endColumn": 15, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 147, + "column": 17, + "endLine": 147, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2812, + "end": 2813, + "replacementText": "1.0", + "line": 147, + "column": 17, + "endLine": 147, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 3, + "endLine": 148, + "endColumn": 6, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 4, + "endLine": 148, + "endColumn": 5, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2840, + "end": 2841, + "replacementText": "2.0", + "line": 148, + "column": 4, + "endLine": 148, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 3, + "endLine": 149, + "endColumn": 34, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 36, + "endLine": 149, + "endColumn": 37, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2914, + "end": 2915, + "replacementText": "3.0", + "line": 149, + "column": 36, + "endLine": 149, + "endColumn": 37 } ], "suggest": "", @@ -1068,7 +1491,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1089,7 +1512,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.json index 7e721f74f1a1f51c82e35dff5046839e4d2c21de..dfce9f6d57c2bbbe9c5508988e3349826cbbdd2d 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.json @@ -144,6 +144,36 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 142, + "column": 3, + "endLine": 142, + "endColumn": 6, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 19, + "endLine": 146, + "endColumn": 20, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 3, + "endLine": 148, + "endColumn": 6, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, { "line": 42, "column": 11, diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets index 54ed22aed80c78711c9c222e7fbe5dc5085f0979..5c91b9deba7f4e2a7a88f7c676e9d6d1d78d21cf 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.ets @@ -95,27 +95,27 @@ LiteralAsPropertyNameEnum.PrivateTwo; { const enum Direction { - __empty = 1, + __empty = 1.0, } } const enum Direction16 { - ___x5c = 1, - __x5c = 1, + ___x5c = 1.0, + __x5c = 1.0, } const enum Direction17 { - ___x5c = 1, - __x5c = 1, + ___x5c = 1.0, + __x5c = 1.0, } let case17: number = Direction17.___x5c let case172: number = Direction17.__x5c const enum Direction11 { -__x21x21 = 1, +__x21x21 = 1.0, } const enum Direction23 { -aaa = 1, +aaa = 1.0, } // ArkUI @Component @@ -134,11 +134,23 @@ class A{ let a:A = { age: 30.0} -class B{ +class B { public age: number = 1.0 // error in arkts2 } let obj11: Record = { -['value']: 1.0, // 误扫 -'value2': 1.0 // ok -} \ No newline at end of file + ['value']: 1.0, // Error in arkts 2.0 + 'value2': 1.0 // ok +} + +class CompPropClass { + ['CompProp'] = 1.0; // Error in arkts 2.0 + [2.0] = 'CompProp2'; // Error in arkts 2.0 + [LiteralAsPropertyNameEnum.One] = 3.0; // Error in arkts 2.0 +} + +let compPropObj = { + ['CompProp']: 1.0, // Error in arkts 2.0 + [2.0]: 'CompProp2', // Error in arkts 2.0 + [LiteralAsPropertyNameEnum.One]: 3.0 // Error in arkts 2.0 +}; \ No newline at end of file diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json index 7756bd53973f3ae465790f9582ab044fb5879ed4..2597882d05f618912e22ab34f5aeb90201a194c8 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.migrate.json @@ -74,6 +74,16 @@ "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", "severity": "ERROR" }, + { + "line": 90, + "column": 12, + "endLine": 90, + "endColumn": 31, + "problem": "InteropDirectAccessToTSTypes", + "suggest": "", + "rule": "Cannot access typescript types directly (arkts-interop-ts2s-static-access-ts-type)", + "severity": "ERROR" + }, { "line": 90, "column": 36, @@ -84,6 +94,106 @@ "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", "severity": "ERROR" }, + { + "line": 92, + "column": 1, + "endLine": 92, + "endColumn": 33, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 141, + "column": 37, + "endLine": 141, + "endColumn": 38, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 3, + "endLine": 142, + "endColumn": 12, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 147, + "column": 3, + "endLine": 147, + "endColumn": 15, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 3, + "endLine": 148, + "endColumn": 8, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 3, + "endLine": 149, + "endColumn": 34, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 152, + "column": 19, + "endLine": 152, + "endColumn": 20, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 153, + "column": 3, + "endLine": 153, + "endColumn": 15, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 3, + "endLine": 154, + "endColumn": 8, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 155, + "column": 3, + "endLine": 155, + "endColumn": 34, + "problem": "ComputedPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, { "line": 28, "column": 11, diff --git a/ets2panda/linter/test/main/localBuilder_1.ets.arkts2.json b/ets2panda/linter/test/main/localBuilder_1.ets.arkts2.json index d25d1a3cb3e628d2e1c93e5d29b19d430e622fed..2476b270173391453e64fca61f2021c3c7a6d6bd 100644 --- a/ets2panda/linter/test/main/localBuilder_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/localBuilder_1.ets.arkts2.json @@ -31,7 +31,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -41,7 +41,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 8, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/localBuilder_1.ets.autofix.json b/ets2panda/linter/test/main/localBuilder_1.ets.autofix.json index 03374a941ac15fbb8447ff5882f0c9b24f25192e..70cdea362594e1c5f29af7e004d837c08f46d52a 100644 --- a/ets2panda/linter/test/main/localBuilder_1.ets.autofix.json +++ b/ets2panda/linter/test/main/localBuilder_1.ets.autofix.json @@ -24,7 +24,11 @@ { "start": 676, "end": 689, - "replacementText": "@Builder" + "replacementText": "@Builder", + "line": 21, + "column": 3, + "endLine": 21, + "endColumn": 16 } ], "suggest": "", @@ -41,11 +45,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -58,11 +66,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -75,11 +87,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -92,11 +108,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -109,11 +129,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -126,11 +150,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Entry, Component, State, Row, Text, Column } from '@kit.ArkUI';", + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/make_observed_1.ets.arkts2.json b/ets2panda/linter/test/main/make_observed_1.ets.arkts2.json index 10dbf86c4885419f1a59d2391a152f1bc7f7d9b8..2abf7a1421a9b820d8fa83ae239de5bf4a20d9f6 100644 --- a/ets2panda/linter/test/main/make_observed_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/make_observed_1.ets.arkts2.json @@ -81,7 +81,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/make_observed_2.ets.arkts2.json b/ets2panda/linter/test/main/make_observed_2.ets.arkts2.json index acf1d0da2e4b1e72ca4827a4bb2b5ee836b9b6dc..7a2f092704188f51fd4a723f17855ac9f2a11f71 100644 --- a/ets2panda/linter/test/main/make_observed_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/make_observed_2.ets.arkts2.json @@ -81,7 +81,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/make_observed_3.ets.arkts2.json b/ets2panda/linter/test/main/make_observed_3.ets.arkts2.json index 7323b8589d7c86eab354575d7fe50005bae89b20..731dc882fba70cdf6501066d3d01dd702e2ba76f 100644 --- a/ets2panda/linter/test/main/make_observed_3.ets.arkts2.json +++ b/ets2panda/linter/test/main/make_observed_3.ets.arkts2.json @@ -71,7 +71,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ComponentV2\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Local\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/method_inheritance.ets b/ets2panda/linter/test/main/method_inheritance.ets index ff1895fc91560a5662f08d3eb401caa34da364e0..c92fa1f0d9d509516fdbe3eabe31b71fee67282c 100644 --- a/ets2panda/linter/test/main/method_inheritance.ets +++ b/ets2panda/linter/test/main/method_inheritance.ets @@ -18,7 +18,7 @@ abstract class Y { } class X extends Y { - async getDataByName(name: string, albumUri: string): Promise { + async getDataByName(name: string, albumUri: string): Promise { // error 2 return; } } @@ -38,7 +38,7 @@ abstract class W { } class Q extends W { - async getDataByName(name: string | number, albumUri: string | number): Promise { + async getDataByName(name: string | number, albumUri: string | number): Promise {// error 1 return; }; } @@ -48,7 +48,7 @@ abstract class BaseClass3 { } class IncorrectWiderReturn extends BaseClass3 { - compute(value: string): string | number { + compute(value: string): string | number {// error 1 return value.length > 5 ? value : 0; } } @@ -58,7 +58,7 @@ abstract class BaseClass4 { } class IncorrectMultipleParamMismatch extends BaseClass4 { - setValues(x: string, y: boolean): void { + setValues(x: string, y: boolean): void {// error 2 console.log(x, y); } } @@ -68,7 +68,7 @@ abstract class BaseClass5 { } class IncorrectBothMismatch extends BaseClass5 { - transform(data: number): number | string { + transform(data: number): number | string {// error 2 return data > 10 ? data : "too small"; } } @@ -97,3 +97,122 @@ class CorrectBothWiderParamNarrowReturn extends BaseClass { } +class A1 { + a: number = 0 +} +class B1 { + a: number = 0 +} +class C { + a: number = 0 +} + +class Base { + foo(obj: A1 | B1): void { + console.log("base") + } + foo2(obj: A1 | B1): void { + console.log("base") + } + foo3(obj: A1 | B1 | C): void { + console.log("base") + } +} + +// extends +class Derived extends Base { + foo(obj: A1): void { // error 1 + console.log("Derived:" + obj.a) + } + foo2(): void { // error 1 + console.log("Derived:") + } + foo3(obj: A1 | B1): void { // error 1 + console.log("Derived:") + } +} + +interface BaseI { + foo(obj: A1 | B1):void; + foo2(obj: A1): void; + foo3(obj: A1 | B1 | C): void; +} + +// implements +class Derived2 implements BaseI { + foo(obj: A1): void { // error 1 + console.log("Drived"); + } + foo2(): void { // error 1 + console.log("Drived"); + } + foo3(obj: A1 | B1): void { // error 1 + console.log("Drived"); + } +} + +class Base2 { + foo(): A1|B1 { + console.log("base") + return new A1(); + } + foo2(){ + console.log("base") + // return new A(); + } + foo3(): A1 { + console.log("base") + return new A1(); + } + foo4():void{ + console.log("base") + // return new A(); + } +} + +//extends +class Derived3 extends Base2 { + foo(): A1|B1|C{ // error 1 + console.log("Derived:") + return new A1(); + } + + foo2(): A1{ // error 1 + console.log("Derived:") + return new A1(); + } + + foo3(): A1|B1 { // error 1 + console.log("Derived:") + return new A1(); + } + foo4(): A1{ // error 1 + console.log("Derived:") + return new A1(); + } +} + + +interface Base3 { + foo(): A1|B1 ; + foo2(): void; + foo3(): A1; +} + +// implements +class Derived4 implements Base3 { + foo(): A1|B1|C{ // error 1 + console.log("Derived:") + return new A1(); + } + + foo2(): A1{ // error 1 + console.log("Derived:") + return new A1(); + } + + foo3(): A1|B1 { // error 1 + console.log("Derived:") + return new A1(); + } +} diff --git a/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json b/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json index 717bb1ec00ad2857434448b626a61f51c958acfd..a25dd05807ca2fdea1668cd8bdd4a50061968881 100644 --- a/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json +++ b/ets2panda/linter/test/main/method_inheritance.ets.arkts2.json @@ -133,6 +133,166 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 101, + "column": 15, + "endLine": 101, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 15, + "endLine": 104, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 15, + "endLine": 107, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 7, + "endLine": 124, + "endColumn": 14, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 127, + "column": 3, + "endLine": 127, + "endColumn": 7, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 8, + "endLine": 130, + "endColumn": 20, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 143, + "column": 7, + "endLine": 143, + "endColumn": 14, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 3, + "endLine": 146, + "endColumn": 7, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 8, + "endLine": 149, + "endColumn": 20, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 175, + "column": 10, + "endLine": 175, + "endColumn": 17, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 180, + "column": 11, + "endLine": 180, + "endColumn": 13, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 185, + "column": 11, + "endLine": 185, + "endColumn": 16, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 189, + "column": 11, + "endLine": 189, + "endColumn": 13, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 204, + "column": 10, + "endLine": 204, + "endColumn": 17, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 209, + "column": 11, + "endLine": 209, + "endColumn": 13, + "problem": "MethodInheritRule", + "suggest": "", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", + "severity": "ERROR" + }, + { + "line": 214, + "column": 11, + "endLine": 214, + "endColumn": 16, + "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_sparse_array.ets b/ets2panda/linter/test/main/no_sparse_array.ets index 3298c36c9294e9ca7c6a20a5a0b06add4789a2d5..a543274d466b525ae165219b1de0854029e9d509 100644 --- a/ets2panda/linter/test/main/no_sparse_array.ets +++ b/ets2panda/linter/test/main/no_sparse_array.ets @@ -14,4 +14,5 @@ */ let a = [1, , , 3]; -let b = []; \ No newline at end of file +let b = []; +let c:number[] = []; \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json b/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json index 2a8c937e9f90ac9a473715b3abeaa83c114917ad..edf83e80e8b144d97924fa06509c4daebdb5aa35 100644 --- a/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_sparse_array.ets.arkts2.json @@ -53,6 +53,16 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 17, + "column": 9, + "endLine": 17, + "endColumn": 11, + "problem": "NosparseArray", + "suggest": "", + "rule": "Sparse array is not supported in ArkTS1.2 (arkts-no-sparse-array)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets b/ets2panda/linter/test/main/no_ts_like_smart_type.ets index 3a4d7ee28d66e130c6375b18bfdc3baa0a308241..65ad923c301050f146d7977c211fcec62d9f481b 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets @@ -12,29 +12,53 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// static + +class A { + private static instance:A = new A(); + static get():A { + return A.instance; // + } +} + +class AA { + public static instance?: number; + + getInstance(): number { + if (!AA.instance) { + return 0; + } + return AA.instance; // Error + } +} + class AA1 { - public static instance : number | string; - getInstance(): number { - if (AA1.instance instanceof string) { - return 0; - } - return AA1.instance; // Error + public static instance : Number | String | Object = "smart cast"; + getInstance(): Number { + if (!(AA1.instance instanceof Number)) { + return 0; } + return AA1.instance; // Error + } } class AA2 { - public instance : number | string; - getInstance(): number { - if (this.instance instanceof string) { - return 0; - } - return this.instance; // Error + public instance : Number | String | Object= 'smart cast'; + getInstance(): Number { + if (!(this.instance instanceof Number)) { + return 0; } + return this.instance; // Error + } } -class A { - private static instance:A = new A(); - static get():A { - return A.instance; + +class AA3 { + public instance : number | String | Object = 'string'; + getInstance(): number { + if (this.instance instanceof String) { + return 0; + } else if (this.instance instanceof Object) { + return 1; } + return this.instance; // Error + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json index 45fcc934258a3b05da4885094e7c46c3f8ed2475..d8dd2482a1d8dee31a6959315d9b86a4b67baf2e 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json @@ -15,63 +15,93 @@ ], "result": [ { - "line": 22, - "column": 9, - "endLine": 22, - "endColumn": 29, + "line": 30, + "column": 5, + "endLine": 30, + "endColumn": 24, "problem": "NoTsLikeSmartType", "suggest": "", "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, { - "line": 17, + "line": 28, + "column": 14, + "endLine": 28, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 40, "column": 5, - "endLine": 17, - "endColumn": 46, - "problem": "ClassstaticInitialization", + "endLine": 40, + "endColumn": 25, + "problem": "NoTsLikeSmartType", "suggest": "", - "rule": "The static property has no initializer (arkts-class-static-initialization)", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, { - "line": 20, - "column": 20, - "endLine": 20, - "endColumn": 21, + "line": 38, + "column": 14, + "endLine": 38, + "endColumn": 15, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 32, - "column": 9, - "endLine": 32, - "endColumn": 30, + "line": 50, + "column": 5, + "endLine": 50, + "endColumn": 26, "problem": "NoTsLikeSmartType", "suggest": "", "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, { - "line": 30, - "column": 20, - "endLine": 30, - "endColumn": 21, + "line": 48, + "column": 14, + "endLine": 48, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 5, + "endLine": 62, + "endColumn": 26, + "problem": "NoTsLikeSmartType", + "suggest": "", + "rule": "Smart type differences (arkts-no-ts-like-smart-type)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 14, + "endLine": 58, + "endColumn": 15, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 27, - "column": 12, - "endLine": 27, - "endColumn": 20, - "problem": "StrictDiagnostic", - "suggest": "Property 'instance' has no initializer and is not definitely assigned in the constructor.", - "rule": "Property 'instance' has no initializer and is not definitely assigned in the constructor.", + "line": 60, + "column": 14, + "endLine": 60, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json index b9d40bdd285aa64170a36db11902a97e7d2644a9..ca88f857e960b437dcf767c0ac40be998c8f1236 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json @@ -13,16 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 27, - "column": 12, - "endLine": 27, - "endColumn": 20, - "problem": "StrictDiagnostic", - "suggest": "Property 'instance' has no initializer and is not definitely assigned in the constructor.", - "rule": "Property 'instance' has no initializer and is not definitely assigned in the constructor.", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_tuples_arrays.ets b/ets2panda/linter/test/main/no_tuples_arrays.ets index 93ab572c518a56e3ecb59350ba3da3ffacd46945..1ebcd176a478517a6d3e452b55fd97c9eed5e686 100644 --- a/ets2panda/linter/test/main/no_tuples_arrays.ets +++ b/ets2panda/linter/test/main/no_tuples_arrays.ets @@ -87,4 +87,44 @@ let tuple19: [number, boolean] = array17 as [number, boolean] //error const originalArray: [number] = [1, 2, 3, 4, 5]; const array18 = originalArray.map((value) => value % 2 === 0 ? true : value * 2); let tuple20: [number, boolean] = array18 as [number, boolean] //error -let array20: (number)[] = originalArray as (number)[] //error \ No newline at end of file +let array20: (number)[] = originalArray as (number)[] //error + +const inputArray: readonly [Record, [], () => void] = [ + {}, + [], + () => { + } +]; +const even = (element: Record | [] | (() => void)): boolean => { + return typeof element === 'function'; +}; +const res = inputArray.some(even); // error +console.log("res:" + JSON.stringify(res)); +console.log(''+inputArray.length) // error +console.log(inputArray.toString()) // error +typeof inputArray.toLocaleString(); // error +function getConcat() { + inputArray.concat(); // error + return inputArray.join(','); // error +} +class Demo{ + set(){ + inputArray.slice(1,2); // error + inputArray.indexOf([]); // error + } + get(){ + return inputArray.lastIndexOf([]); // error + } +} +inputArray.every(()=>{}) // error +inputArray.some(()=>{}) // error +inputArray.forEach(()=>{}) // error +inputArray.map(()=>{}) // error +inputArray.filter(()=>{}) // error +inputArray.reduce((acc, item) => acc + 1, 0); // error +inputArray.reduceRight((acc, item) => acc + 1, 0); // error +inputArray.find((item) => Array.isArray(item)); // error +inputArray.includes(() => {}); // error +inputArray.flat() // error +inputArray.flatMap((item) => [item]); // error +inputArray.findIndex((item) => typeof item === 'function'); // error \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json b/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json index f4753e594f424b6cdff8b4dbd33f47f0819ae200..e578984b4483e2a7fa197aea6c1a88a7160e5380 100644 --- a/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_tuples_arrays.ets.arkts2.json @@ -64,16 +64,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 25, - "column": 13, - "endLine": 25, - "endColumn": 59, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 29, "column": 30, @@ -94,6 +84,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 30, + "column": 16, + "endLine": 30, + "endColumn": 21, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 33, "column": 23, @@ -114,16 +114,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 39, - "column": 13, - "endLine": 39, - "endColumn": 62, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 63, "column": 43, @@ -154,16 +144,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 65, - "column": 7, - "endLine": 65, - "endColumn": 42, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 67, "column": 7, @@ -174,16 +154,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 67, - "column": 7, - "endLine": 67, - "endColumn": 53, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 68, "column": 7, @@ -194,16 +164,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 68, - "column": 7, - "endLine": 68, - "endColumn": 53, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 70, "column": 5, @@ -214,16 +174,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 70, - "column": 5, - "endLine": 70, - "endColumn": 53, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 73, "column": 5, @@ -234,16 +184,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 73, - "column": 5, - "endLine": 73, - "endColumn": 43, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 74, "column": 5, @@ -254,16 +194,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 74, - "column": 5, - "endLine": 74, - "endColumn": 48, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 75, "column": 5, @@ -274,16 +204,6 @@ "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" }, - { - "line": 75, - "column": 5, - "endLine": 75, - "endColumn": 50, - "problem": "ArrayTypeImmutable", - "suggest": "", - "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", - "severity": "ERROR" - }, { "line": 78, "column": 35, @@ -454,6 +374,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 88, + "column": 17, + "endLine": 88, + "endColumn": 34, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, { "line": 88, "column": 54, @@ -503,6 +433,276 @@ "suggest": "", "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", "severity": "ERROR" + }, + { + "line": 101, + "column": 13, + "endLine": 101, + "endColumn": 28, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 16, + "endLine": 103, + "endColumn": 33, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 13, + "endLine": 104, + "endColumn": 32, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 8, + "endLine": 105, + "endColumn": 33, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 3, + "endLine": 107, + "endColumn": 20, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 10, + "endLine": 108, + "endColumn": 25, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 5, + "endLine": 112, + "endColumn": 21, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 22, + "endLine": 112, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 24, + "endLine": 112, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 5, + "endLine": 113, + "endColumn": 23, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 12, + "endLine": 116, + "endColumn": 34, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 119, + "column": 1, + "endLine": 119, + "endColumn": 17, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 1, + "endLine": 120, + "endColumn": 16, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 1, + "endLine": 121, + "endColumn": 19, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 122, + "column": 1, + "endLine": 122, + "endColumn": 15, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 1, + "endLine": 123, + "endColumn": 18, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 1, + "endLine": 124, + "endColumn": 18, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 40, + "endLine": 124, + "endColumn": 41, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 43, + "endLine": 124, + "endColumn": 44, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 1, + "endLine": 125, + "endColumn": 23, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 45, + "endLine": 125, + "endColumn": 46, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 48, + "endLine": 125, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 1, + "endLine": 126, + "endColumn": 16, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 127, + "column": 1, + "endLine": 127, + "endColumn": 20, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 1, + "endLine": 128, + "endColumn": 16, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 129, + "column": 1, + "endLine": 129, + "endColumn": 19, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 1, + "endLine": 130, + "endColumn": 21, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets b/ets2panda/linter/test/main/numeric_semantics.ets index e09d8b47cf7c1fe4bde0f446600b80eaa943059f..ff1a6aece731d3229c75072c5204a7f8df53a80f 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets @@ -202,4 +202,26 @@ for (let i:number = 0; i < 100; i++) { } let cancelIds:ArrayList = arr.subArrayList(6, 86) let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) \ No newline at end of file +let arr1: Array = Array.from(new ArrayList()) + +let a:number = 0.000; + +const b:number = 0.000; + +export enum WalletStageValue { + DEFAULT = 0, + SWIPE_INIT = -1, + SELECT_CARD = 1, + SWIPE_DOING = 2, + SWIPE_SUCCEED = 3, + SWIPE_FAILED = 4, + SWIPE_FINISHED = 5, +} + +export enum AnimationStage { + INIT = 0, + ENTER = 1, + ROTATING = 2, + EXIT_START = 3, + EXIT_END = 4, +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json old mode 100755 new mode 100644 index d8d76c5ce87c4221590181e6ea52baac523f6e38..569ac92a4c9ead6b27ddfa63680d66f4d4d410bd --- a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json @@ -504,6 +504,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 112, + "column": 7, + "endLine": 112, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 7, + "endLine": 113, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 115, "column": 7, @@ -964,6 +984,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 183, + "column": 6, + "endLine": 183, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 185, "column": 5, @@ -1074,6 +1104,126 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 212, + "column": 13, + "endLine": 212, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 213, + "column": 17, + "endLine": 213, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 214, + "column": 17, + "endLine": 214, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 215, + "column": 17, + "endLine": 215, + "endColumn": 18, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 216, + "column": 19, + "endLine": 216, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 18, + "endLine": 217, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 20, + "endLine": 218, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 222, + "column": 10, + "endLine": 222, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 223, + "column": 11, + "endLine": 223, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 14, + "endLine": 224, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 16, + "endLine": 225, + "endColumn": 17, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 14, + "endLine": 226, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -1081,7 +1231,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1091,7 +1241,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1101,7 +1251,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1111,7 +1261,7 @@ "endColumn": 22, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"RelativeContainer\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1121,7 +1271,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1131,7 +1281,7 @@ "endColumn": 40, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1141,7 +1291,7 @@ "endColumn": 56, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1151,7 +1301,7 @@ "endColumn": 43, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -1161,7 +1311,7 @@ "endColumn": 44, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json index 148d39bc8276e8eda806b5d3325102c8b6e58239..2c6c4de6cffb11ee9758bc18ad36cc5d75939a53 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json @@ -704,9 +704,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2067, + "start": 2066, "end": 2070, - "replacementText": "234.0", + "replacementText": "-234.0", "line": 85, "column": 11, "endLine": 85, @@ -1063,6 +1063,48 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 112, + "column": 7, + "endLine": 112, + "endColumn": 8, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2446, + "end": 2447, + "replacementText": "1.0", + "line": 112, + "column": 7, + "endLine": 112, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 7, + "endLine": 113, + "endColumn": 8, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2468, + "end": 2469, + "replacementText": "2.0", + "line": 113, + "column": 7, + "endLine": 113, + "endColumn": 8 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 115, "column": 7, @@ -1626,9 +1668,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3357, + "start": 3356, "end": 3358, - "replacementText": "1.0", + "replacementText": "-1.0", "line": 149, "column": 17, "endLine": 149, @@ -1647,9 +1689,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3361, + "start": 3360, "end": 3362, - "replacementText": "1.0", + "replacementText": "-1.0", "line": 149, "column": 21, "endLine": 149, @@ -1963,6 +2005,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 183, + "column": 6, + "endLine": 183, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 185, "column": 5, @@ -2150,6 +2202,258 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, + { + "line": 212, + "column": 13, + "endLine": 212, + "endColumn": 14, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5206, + "end": 5207, + "replacementText": "0.0", + "line": 212, + "column": 13, + "endLine": 212, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 213, + "column": 17, + "endLine": 213, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5225, + "end": 5227, + "replacementText": "-1.0", + "line": 213, + "column": 17, + "endLine": 213, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 214, + "column": 17, + "endLine": 214, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5246, + "end": 5247, + "replacementText": "1.0", + "line": 214, + "column": 17, + "endLine": 214, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 215, + "column": 17, + "endLine": 215, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5266, + "end": 5267, + "replacementText": "2.0", + "line": 215, + "column": 17, + "endLine": 215, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 216, + "column": 19, + "endLine": 216, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5288, + "end": 5289, + "replacementText": "3.0", + "line": 216, + "column": 19, + "endLine": 216, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 18, + "endLine": 217, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5309, + "end": 5310, + "replacementText": "4.0", + "line": 217, + "column": 18, + "endLine": 217, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 20, + "endLine": 218, + "endColumn": 21, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5332, + "end": 5333, + "replacementText": "5.0", + "line": 218, + "column": 20, + "endLine": 218, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 222, + "column": 10, + "endLine": 222, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5380, + "end": 5381, + "replacementText": "0.0", + "line": 222, + "column": 10, + "endLine": 222, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 223, + "column": 11, + "endLine": 223, + "endColumn": 12, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5394, + "end": 5395, + "replacementText": "1.0", + "line": 223, + "column": 11, + "endLine": 223, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 14, + "endLine": 224, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5411, + "end": 5412, + "replacementText": "2.0", + "line": 224, + "column": 14, + "endLine": 224, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 16, + "endLine": 225, + "endColumn": 17, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5430, + "end": 5431, + "replacementText": "3.0", + "line": 225, + "column": 16, + "endLine": 225, + "endColumn": 17 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 14, + "endLine": 226, + "endColumn": 15, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5447, + "end": 5448, + "replacementText": "4.0", + "line": 226, + "column": 14, + "endLine": 226, + "endColumn": 15 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -2168,7 +2472,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2189,7 +2493,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2210,7 +2514,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2231,7 +2535,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"RelativeContainer\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2252,7 +2556,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2273,7 +2577,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2294,7 +2598,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2315,7 +2619,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -2336,7 +2640,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets index cecf097403e7e26cc5170fc8585ae18efaf67337..ba4df96e9d5d2547d6a0d26396cb8d9769ab96e1 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets @@ -112,8 +112,8 @@ let g: number = an_array[] const a: number = 1.0 enum Test { - A = 1, // 显式赋值为 1 - B = 2 // 显式赋值为 2 + A = 1.0, // 显式赋值为 1 + B = 2.0 // 显式赋值为 2 } const test: number = Test.A; @@ -208,4 +208,26 @@ for (let i:number = 0.0; i < 100.0; i++) { } let cancelIds:ArrayList = arr.subArrayList(6.0, 86.0) let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) \ No newline at end of file +let arr1: Array = Array.from(new ArrayList()) + +let a:number = 0.000; + +const b:number = 0.000; + +export enum WalletStageValue { + DEFAULT = 0.0, + SWIPE_INIT = -1.0, + SELECT_CARD = 1.0, + SWIPE_DOING = 2.0, + SWIPE_SUCCEED = 3.0, + SWIPE_FAILED = 4.0, + SWIPE_FINISHED = 5.0, +} + +export enum AnimationStage { + INIT = 0.0, + ENTER = 1.0, + ROTATING = 2.0, + EXIT_START = 3.0, + EXIT_END = 4.0, +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json index c86c2373e15de875d2b44d53c7a5dc66cf1713bf..665c1dea057b93e293c9171fa2397e962d108f95 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json @@ -74,6 +74,16 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 189, + "column": 6, + "endLine": 189, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 203, "column": 1, diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json index 0b572f009af85043603d7fd6254a8a4ff384c34f..8c2a778ec9f98e3debce809d5fc606ab7aa784bc 100755 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.arkts2.json @@ -204,6 +204,46 @@ "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", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 13, + "endLine": 63, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 68, "column": 28, diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json index e649323550046bb28030db18baa72b90cdfdd326..890005064bf088396c63cd5becc06be2048344e5 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json @@ -419,6 +419,68 @@ "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, diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets index db5e2adfbe6a5554f1cd828d4ddf012da092cd75..3b6d90963de29a91d2956a234c216cf8b9eae545 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.ets @@ -61,8 +61,8 @@ namespace NoNumericSemantics { let h: number = arr[12. as int] enum E { - A = 1, - B = 2 + A = 1.0, + B = 2.0 } } diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json index 2b4699fa61f8fc34e602920f4759be0300caa0ae..dcabd25e6925cd145c328b6fb0ebe92814d1e4a3 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.migrate.json @@ -74,6 +74,26 @@ "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, diff --git a/ets2panda/linter/test/main/object_literals_properties.ets b/ets2panda/linter/test/main/object_literals_properties.ets index d5265f74931ccea9f47fc03753efec7076b19d3b..84c1d5db860e0f4e0d5f200b21e71e7b7b8741d0 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets +++ b/ets2panda/linter/test/main/object_literals_properties.ets @@ -244,15 +244,42 @@ let b3: Derived3 = { // Fixable m() { console.log(2); } }; -interface A { +interface I4 { map: Map; } let map:Map = new Map(); -let a:A = {map}; +let i4: I4 = {map}; -class C { +class C6 { map1: Map = new Map(); } let map1:Map = new Map(); -let c:C = {map1}; \ No newline at end of file +let c6: C6 = {map1}; + +// Namespace typed object literals +namespace X { + export class C { + m() { + console.log("C - 1"); + } + } + + export interface I { + m(a: number, b: string): void; + } +} + +function test() { + let c: X.C = { + m() { + console.log("C - 2"); + } + } + + let i: X.I = { + m(): void { + console.log("I"); + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json b/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json index cc12e25c14161a7519fb9115fec3540ee4a842d2..4f42a0f593f239b67d468925e2630974976a6fc9 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.arkts2.json @@ -124,6 +124,36 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 34, + "column": 3, + "endLine": 34, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 3, + "endLine": 36, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 39, "column": 14, @@ -164,6 +194,26 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 47, + "column": 3, + "endLine": 47, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 3, + "endLine": 48, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 50, "column": 3, @@ -334,6 +384,36 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 69, + "column": 3, + "endLine": 69, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 3, + "endLine": 70, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 3, + "endLine": 71, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 72, "column": 3, @@ -554,6 +634,36 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 110, + "column": 3, + "endLine": 110, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 3, + "endLine": 111, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 3, + "endLine": 112, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 113, "column": 3, @@ -584,6 +694,36 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 117, + "column": 3, + "endLine": 117, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 3, + "endLine": 118, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 119, + "column": 3, + "endLine": 119, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 120, "column": 3, @@ -694,6 +834,36 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 134, + "column": 3, + "endLine": 134, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 3, + "endLine": 135, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 137, "column": 3, @@ -1024,6 +1194,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 226, + "column": 16, + "endLine": 226, + "endColumn": 29, + "problem": "MissingSuperCall", + "suggest": "", + "rule": "The subclass constructor must call the parent class's parametered constructor (arkts-subclass-must-call-super-constructor-with-args)", + "severity": "ERROR" + }, { "line": 229, "column": 20, @@ -1094,16 +1274,66 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 251, + "column": 15, + "endLine": 251, + "endColumn": 18, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 258, - "column": 11, + "column": 15, "endLine": 258, - "endColumn": 12, + "endColumn": 19, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 274, + "column": 16, + "endLine": 274, + "endColumn": 17, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 275, + "column": 5, + "endLine": 277, + "endColumn": 6, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 280, + "column": 16, + "endLine": 280, + "endColumn": 17, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 281, + "column": 5, + "endLine": 283, + "endColumn": 6, + "problem": "ObjectLiteralProperty", + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 187, "column": 3, diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json index 8e5ca8740328ce6d6ff6e2c7106760e138b5718d..04eed5c40725e7ae3e575caa83ea8b14ab9a98fc 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json @@ -228,6 +228,69 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 34, + "column": 3, + "endLine": 34, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 922, + "end": 923, + "replacementText": "x: x", + "line": 34, + "column": 3, + "endLine": 34, + "endColumn": 4 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 945, + "end": 946, + "replacementText": "y: y", + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 4 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 3, + "endLine": 36, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 968, + "end": 969, + "replacementText": "z: z", + "line": 36, + "column": 3, + "endLine": 36, + "endColumn": 4 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 39, "column": 14, @@ -288,6 +351,48 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 47, + "column": 3, + "endLine": 47, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1112, + "end": 1113, + "replacementText": "x: x", + "line": 47, + "column": 3, + "endLine": 47, + "endColumn": 4 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 3, + "endLine": 48, + "endColumn": 4, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1126, + "end": 1127, + "replacementText": "y: y", + "line": 48, + "column": 3, + "endLine": 48, + "endColumn": 4 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 50, "column": 3, @@ -601,6 +706,69 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 69, + "column": 3, + "endLine": 69, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1425, + "end": 1427, + "replacementText": "x2: x2", + "line": 69, + "column": 3, + "endLine": 69, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 3, + "endLine": 70, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1449, + "end": 1451, + "replacementText": "y2: y2", + "line": 70, + "column": 3, + "endLine": 70, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 3, + "endLine": 71, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1473, + "end": 1475, + "replacementText": "z2: z2", + "line": 71, + "column": 3, + "endLine": 71, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 72, "column": 3, @@ -1013,6 +1181,69 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 110, + "column": 3, + "endLine": 110, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1926, + "end": 1928, + "replacementText": "x2: x2", + "line": 110, + "column": 3, + "endLine": 110, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 3, + "endLine": 111, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1943, + "end": 1945, + "replacementText": "y2: y2", + "line": 111, + "column": 3, + "endLine": 111, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 3, + "endLine": 112, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 1960, + "end": 1962, + "replacementText": "z2: z2", + "line": 112, + "column": 3, + "endLine": 112, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 113, "column": 3, @@ -1074,6 +1305,69 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 117, + "column": 3, + "endLine": 117, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 2034, + "end": 2036, + "replacementText": "x2: x2", + "line": 117, + "column": 3, + "endLine": 117, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 3, + "endLine": 118, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 2051, + "end": 2053, + "replacementText": "y2: y2", + "line": 118, + "column": 3, + "endLine": 118, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 119, + "column": 3, + "endLine": 119, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 2068, + "end": 2070, + "replacementText": "z2: z2", + "line": 119, + "column": 3, + "endLine": 119, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 120, "column": 3, @@ -1261,6 +1555,69 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 134, + "column": 3, + "endLine": 134, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 2289, + "end": 2291, + "replacementText": "x2: x2", + "line": 134, + "column": 3, + "endLine": 134, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 135, + "column": 3, + "endLine": 135, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 2306, + "end": 2308, + "replacementText": "y2: y2", + "line": 135, + "column": 3, + "endLine": 135, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 5, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 2323, + "end": 2325, + "replacementText": "z2: z2", + "line": 136, + "column": 3, + "endLine": 136, + "endColumn": 5 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 137, "column": 3, @@ -1776,6 +2133,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 226, + "column": 16, + "endLine": 226, + "endColumn": 29, + "problem": "MissingSuperCall", + "suggest": "", + "rule": "The subclass constructor must call the parent class's parametered constructor (arkts-subclass-must-call-super-constructor-with-args)", + "severity": "ERROR" + }, { "line": 229, "column": 20, @@ -1899,16 +2266,128 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 251, + "column": 15, + "endLine": 251, + "endColumn": 18, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 4619, + "end": 4622, + "replacementText": "map: map", + "line": 251, + "column": 15, + "endLine": 251, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 258, - "column": 11, + "column": 15, "endLine": 258, - "endColumn": 12, + "endColumn": 19, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 4766, + "end": 4770, + "replacementText": "map1: map1", + "line": 258, + "column": 15, + "endLine": 258, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 274, + "column": 16, + "endLine": 274, + "endColumn": 17, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 275, + "column": 5, + "endLine": 277, + "endColumn": 6, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 4958, + "end": 4958, + "replacementText": "class GeneratedObjectLiteralClass_11 extends X.C {\n m() {\n console.log(\"C - 2\");\n }\n}\n\n", + "line": 275, + "column": 5, + "endLine": 277, + "endColumn": 6 + }, + { + "start": 4991, + "end": 5040, + "replacementText": "new GeneratedObjectLiteralClass_11()", + "line": 275, + "column": 5, + "endLine": 277, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, + { + "line": 280, + "column": 16, + "endLine": 280, + "endColumn": 17, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", "severity": "ERROR" }, + { + "line": 281, + "column": 5, + "endLine": 283, + "endColumn": 6, + "problem": "ObjectLiteralProperty", + "autofix": [ + { + "start": 4958, + "end": 4958, + "replacementText": "class GeneratedObjectLiteralClass_12 implements X.I {\n m(): void {\n console.log(\"I\");\n }\n}\n\n", + "line": 281, + "column": 5, + "endLine": 283, + "endColumn": 6 + }, + { + "start": 5058, + "end": 5109, + "replacementText": "new GeneratedObjectLiteralClass_12()", + "line": 281, + "column": 5, + "endLine": 283, + "endColumn": 6 + } + ], + "suggest": "", + "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "severity": "ERROR" + }, { "line": 187, "column": 3, diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.json b/ets2panda/linter/test/main/object_literals_properties.ets.json index 8548318c10fef89543ca13c38b6e81e90ce6a607..97cb35867cee19acd5d2782fa51f2cc23bdc5f80 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.json @@ -295,10 +295,20 @@ "severity": "ERROR" }, { - "line": 258, - "column": 11, - "endLine": 258, - "endColumn": 12, + "line": 274, + "column": 16, + "endLine": 274, + "endColumn": 17, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 280, + "column": 16, + "endLine": 280, + "endColumn": 17, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets index eb3a50b921ec2d55d356fce7716ddd3fe683f8a8..c2c24296503bfb2c9c06af0882c3e9dd3ea8e123 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets +++ b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.ets @@ -36,10 +36,15 @@ let setMethod = new GeneratedObjectLiteralClass_3(); let x: number = 1.0, y = '2', z = true; -let shorthand = { - x, // Error, fixable - y, // Error, fixable - z // Error, fixable +interface GeneratedObjectLiteralInterface_1 { + x: number; + y: string; + z: boolean; +} +let shorthand: GeneratedObjectLiteralInterface_1 = { + x: x, // Error, fixable + y: y, // Error, fixable + z: z // Error, fixable }; let spread = { @@ -92,9 +97,9 @@ let x2: number = 1.0, y2: number = 2.0, z2: number = 3.0; let mixedBad = { // Not fixable a: 1.0, b: 2.0, - x2, // Error, fixable - y2, // Error, fixable - z2, // Error, fixable + x2: x2, // Error, fixable + y2: y2, // Error, fixable + z2: z2, // Error, fixable m() {}, ...shorthand // Error, not fixable } @@ -142,7 +147,7 @@ class GeneratedObjectLiteralClass_8 extends C2 { x2: number; y2: number; z2: number; - constructor(init: GeneratedObjectLiteralInitInterface_8) { + constructor(init: GeneratedObjectLiteralInitInterface_1) { super(); this.x2 = init.x2; this.y2 = init.y2; @@ -151,7 +156,7 @@ class GeneratedObjectLiteralClass_8 extends C2 { m() { console.log(1.0); } // Fixable } -interface GeneratedObjectLiteralInitInterface_8 { +interface GeneratedObjectLiteralInitInterface_1 { x2: number; y2: number; z2: number; @@ -164,9 +169,9 @@ let c2: C2 = new GeneratedObjectLiteralClass_8({ }); let c22: C2 = { - x2, // Fixable - y2, // Fixable - z2, // Fixable + x2: x2, // Fixable + y2: y2, // Fixable + z2: z2, // Fixable m() { console.log(1.0); }, // Not fixable, object has spread property ...shorthand // Not fixable }; @@ -181,9 +186,9 @@ class C3 { constructor(a: number) {} } let c3: C3 = { - x2, // Fixable - y2, // Fixable - z2, // Fixable + x2: x2, // Fixable + y2: y2, // Fixable + z2: z2, // Fixable m() { console.log(1.0); } // Not fixable, class type has constructor with parameters }; @@ -301,15 +306,46 @@ class GeneratedObjectLiteralClass_10 extends Derived3 { let b3: Derived3 = new GeneratedObjectLiteralClass_10(); -interface A { +interface I4 { map: Map; } let map:Map = new Map(); -let a:A = {map}; +let i4: I4 = {map: map}; -class C { +class C6 { map1: Map = new Map(); } let map1:Map = new Map(); -let c:C = {map1}; \ No newline at end of file +let c6: C6 = {map1: map1}; + +// Namespace typed object literals +namespace X { + export class C { + m() { + console.log("C - 1"); + } + } + + export interface I { + m(a: number, b: string): void; + } +} + +class GeneratedObjectLiteralClass_11 extends X.C { + m() { + console.log("C - 2"); + } +} + +class GeneratedObjectLiteralClass_12 implements X.I { + m(): void { + console.log("I"); + } +} + +function test() { + let c: X.C = new GeneratedObjectLiteralClass_11() + + let i: X.I = new GeneratedObjectLiteralClass_12() +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json index 9143d0676d166e6b9291a69bf5f6a0bbf880a2b3..b652f8984b042e4ff3b80b0521adea79db14aef4 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.migrate.json @@ -15,19 +15,9 @@ ], "result": [ { - "line": 39, - "column": 17, - "endLine": 39, - "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": 45, + "line": 50, "column": 14, - "endLine": 45, + "endLine": 50, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -35,9 +25,9 @@ "severity": "ERROR" }, { - "line": 46, + "line": 51, "column": 3, - "endLine": 46, + "endLine": 51, "endColumn": 15, "problem": "ObjectLiteralProperty", "suggest": "", @@ -45,9 +35,9 @@ "severity": "ERROR" }, { - "line": 46, + "line": 51, "column": 3, - "endLine": 46, + "endLine": 51, "endColumn": 15, "problem": "SpreadOperator", "suggest": "", @@ -55,9 +45,9 @@ "severity": "ERROR" }, { - "line": 92, + "line": 97, "column": 16, - "endLine": 92, + "endLine": 97, "endColumn": 17, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -65,9 +55,9 @@ "severity": "ERROR" }, { - "line": 98, + "line": 103, "column": 3, - "endLine": 98, + "endLine": 103, "endColumn": 9, "problem": "ObjectLiteralProperty", "suggest": "", @@ -75,9 +65,9 @@ "severity": "ERROR" }, { - "line": 99, + "line": 104, "column": 3, - "endLine": 99, + "endLine": 104, "endColumn": 15, "problem": "ObjectLiteralProperty", "suggest": "", @@ -85,9 +75,9 @@ "severity": "ERROR" }, { - "line": 99, + "line": 104, "column": 3, - "endLine": 99, + "endLine": 104, "endColumn": 15, "problem": "SpreadOperator", "suggest": "", @@ -95,9 +85,9 @@ "severity": "ERROR" }, { - "line": 166, + "line": 171, "column": 15, - "endLine": 166, + "endLine": 171, "endColumn": 16, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -105,9 +95,9 @@ "severity": "ERROR" }, { - "line": 170, + "line": 175, "column": 3, - "endLine": 170, + "endLine": 175, "endColumn": 28, "problem": "ObjectLiteralProperty", "suggest": "", @@ -115,9 +105,9 @@ "severity": "ERROR" }, { - "line": 171, + "line": 176, "column": 3, - "endLine": 171, + "endLine": 176, "endColumn": 15, "problem": "ObjectLiteralProperty", "suggest": "", @@ -125,9 +115,9 @@ "severity": "ERROR" }, { - "line": 171, + "line": 176, "column": 3, - "endLine": 171, + "endLine": 176, "endColumn": 15, "problem": "SpreadOperator", "suggest": "", @@ -135,9 +125,9 @@ "severity": "ERROR" }, { - "line": 183, + "line": 188, "column": 14, - "endLine": 183, + "endLine": 188, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -145,9 +135,9 @@ "severity": "ERROR" }, { - "line": 187, + "line": 192, "column": 3, - "endLine": 187, + "endLine": 192, "endColumn": 28, "problem": "ObjectLiteralProperty", "suggest": "", @@ -155,9 +145,9 @@ "severity": "ERROR" }, { - "line": 192, + "line": 197, "column": 25, - "endLine": 192, + "endLine": 197, "endColumn": 26, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -165,9 +155,9 @@ "severity": "ERROR" }, { - "line": 193, + "line": 198, "column": 5, - "endLine": 195, + "endLine": 200, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -175,9 +165,9 @@ "severity": "ERROR" }, { - "line": 198, + "line": 203, "column": 29, - "endLine": 198, + "endLine": 203, "endColumn": 30, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -185,9 +175,9 @@ "severity": "ERROR" }, { - "line": 199, + "line": 204, "column": 5, - "endLine": 201, + "endLine": 206, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -195,9 +185,9 @@ "severity": "ERROR" }, { - "line": 209, + "line": 214, "column": 26, - "endLine": 209, + "endLine": 214, "endColumn": 27, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -205,9 +195,9 @@ "severity": "ERROR" }, { - "line": 210, + "line": 215, "column": 5, - "endLine": 212, + "endLine": 217, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -215,9 +205,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 219, "column": 27, - "endLine": 214, + "endLine": 219, "endColumn": 28, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -225,9 +215,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 220, "column": 5, - "endLine": 217, + "endLine": 222, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -235,9 +225,9 @@ "severity": "ERROR" }, { - "line": 221, + "line": 226, "column": 27, - "endLine": 221, + "endLine": 226, "endColumn": 28, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -245,9 +235,9 @@ "severity": "ERROR" }, { - "line": 222, + "line": 227, "column": 5, - "endLine": 224, + "endLine": 229, "endColumn": 6, "problem": "ObjectLiteralProperty", "suggest": "", @@ -255,9 +245,9 @@ "severity": "ERROR" }, { - "line": 233, + "line": 238, "column": 14, - "endLine": 233, + "endLine": 238, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -265,9 +255,9 @@ "severity": "ERROR" }, { - "line": 244, + "line": 249, "column": 3, - "endLine": 244, + "endLine": 249, "endColumn": 9, "problem": "ObjectLiteralProperty", "suggest": "", @@ -275,9 +265,9 @@ "severity": "ERROR" }, { - "line": 251, + "line": 256, "column": 14, - "endLine": 251, + "endLine": 256, "endColumn": 15, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -285,9 +275,9 @@ "severity": "ERROR" }, { - "line": 262, + "line": 267, "column": 3, - "endLine": 262, + "endLine": 267, "endColumn": 9, "problem": "ObjectLiteralProperty", "suggest": "", @@ -295,9 +285,19 @@ "severity": "ERROR" }, { - "line": 284, + "line": 286, + "column": 16, + "endLine": 286, + "endColumn": 29, + "problem": "MissingSuperCall", + "suggest": "", + "rule": "The subclass constructor must call the parent class's parametered constructor (arkts-subclass-must-call-super-constructor-with-args)", + "severity": "ERROR" + }, + { + "line": 289, "column": 20, - "endLine": 284, + "endLine": 289, "endColumn": 21, "problem": "ObjectLiteralNoContextType", "suggest": "", @@ -305,9 +305,9 @@ "severity": "ERROR" }, { - "line": 285, + "line": 290, "column": 3, - "endLine": 285, + "endLine": 290, "endColumn": 28, "problem": "ObjectLiteralProperty", "suggest": "", @@ -315,19 +315,19 @@ "severity": "ERROR" }, { - "line": 315, - "column": 11, - "endLine": 315, - "endColumn": 12, - "problem": "ObjectLiteralNoContextType", + "line": 342, + "column": 5, + "endLine": 342, + "endColumn": 6, + "problem": "MethodInheritRule", "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "rule": "Overridden method parameters and return types must respect type inheritance principles (arkts-method-inherit-rule)", "severity": "ERROR" }, { - "line": 240, + "line": 245, "column": 3, - "endLine": 240, + "endLine": 245, "endColumn": 4, "problem": "StrictDiagnostic", "suggest": "Property 'b' has no initializer and is not definitely assigned in the constructor.", diff --git a/ets2panda/linter/test/main/parameter_properties.ets.arkts2.json b/ets2panda/linter/test/main/parameter_properties.ets.arkts2.json index 70d8cbcfa4df48aa1d164eeb6c88d7ce540829db..a4cd69b2173b1a88ba75033250ea92bf6425fb14 100644 --- a/ets2panda/linter/test/main/parameter_properties.ets.arkts2.json +++ b/ets2panda/linter/test/main/parameter_properties.ets.arkts2.json @@ -84,6 +84,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 34, + "column": 33, + "endLine": 34, + "endColumn": 34, + "problem": "DefaultArgsBehindRequiredArgs", + "suggest": "", + "rule": "Default parameters must be placed after mandatory parameters (arkts-default-args-behind-required-args)", + "severity": "ERROR" + }, { "line": 34, "column": 26, diff --git a/ets2panda/linter/test/main/parameter_properties.ets.autofix.json b/ets2panda/linter/test/main/parameter_properties.ets.autofix.json index cd0ccd75eea12792b175ccd228d33d91e6cb5b8f..6e139d8b9efbcf3d68ec3cd90f849f418ed88c76 100644 --- a/ets2panda/linter/test/main/parameter_properties.ets.autofix.json +++ b/ets2panda/linter/test/main/parameter_properties.ets.autofix.json @@ -269,6 +269,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 34, + "column": 33, + "endLine": 34, + "endColumn": 34, + "problem": "DefaultArgsBehindRequiredArgs", + "suggest": "", + "rule": "Default parameters must be placed after mandatory parameters (arkts-default-args-behind-required-args)", + "severity": "ERROR" + }, { "line": 34, "column": 26, diff --git a/ets2panda/linter/test/main/parameter_properties.ets.migrate.json b/ets2panda/linter/test/main/parameter_properties.ets.migrate.json index 03cac9f4e47f0a3b2f7cc5966991917f603ee4d0..f5bbbab5413b751bcc375dc9c7b788749e4839a7 100644 --- a/ets2panda/linter/test/main/parameter_properties.ets.migrate.json +++ b/ets2panda/linter/test/main/parameter_properties.ets.migrate.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 43, + "column": 24, + "endLine": 43, + "endColumn": 25, + "problem": "DefaultArgsBehindRequiredArgs", + "suggest": "", + "rule": "Default parameters must be placed after mandatory parameters (arkts-default-args-behind-required-args)", + "severity": "ERROR" + }, { "line": 54, "column": 15, diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.args.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..ee0734c0fc5b9a918bfdd7245e6ef1efeb8ad7e6 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets.arkts2.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.arkts2.json similarity index 68% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets.arkts2.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.arkts2.json index 2bf08fd4ccfd72ff49c58ef08d1ae0df86136eb1..a652bb026f9974b81a126fe5b958e6359043abac 100644 --- a/ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.arkts2.json @@ -61,7 +61,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -71,17 +71,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 4, - "endLine": 24, - "endColumn": 8, - "problem": "UIInterfaceImport", - "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +81,7 @@ "endColumn": 15, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"StorageLink\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +91,7 @@ "endColumn": 20, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"LocalStorageLink\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,27 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", - "severity": "ERROR" - }, - { - "line": 34, - "column": 4, - "endLine": 34, - "endColumn": 15, - "problem": "UIInterfaceImport", - "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", - "severity": "ERROR" - }, - { - "line": 35, - "column": 4, - "endLine": 35, - "endColumn": 20, - "problem": "UIInterfaceImport", - "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..7749390fd7bfdd19f8e62c6fe159a421af5a4df8 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.autofix.json @@ -0,0 +1,207 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 18, + "column": 17, + "endLine": 18, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 654, + "end": 655, + "replacementText": "0.0", + "line": 18, + "column": 17, + "endLine": 18, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 3, + "endLine": 24, + "endColumn": 33, + "problem": "PropDecoratorNotSupported", + "autofix": [ + { + "start": 704, + "end": 709, + "replacementText": "@PropRef", + "line": 24, + "column": 3, + "endLine": 24, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "\"@Prop\" decorator is not supported (arkui-no-prop-decorator)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 3, + "endLine": 34, + "endColumn": 49, + "problem": "StoragePropDecoratorNotSupported", + "autofix": [ + { + "start": 895, + "end": 916, + "replacementText": "@StoragePropRef", + "line": 34, + "column": 3, + "endLine": 34, + "endColumn": 49 + } + ], + "suggest": "", + "rule": "\"@StorageProp\" decorator is not supported (arkui-no-storageprop-decorator)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 54, + "problem": "LocalStoragePropDecoratorNotSupported", + "autofix": [ + { + "start": 944, + "end": 970, + "replacementText": "@LocalStoragePropRef", + "line": 35, + "column": 3, + "endLine": 35, + "endColumn": 54 + } + ], + "suggest": "", + "rule": "\"@LocalStorageProp\" decorator is not supported (arkui-no-localstorageprop-decorator)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 2, + "endLine": 21, + "endColumn": 7, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, StorageLink, LocalStorageLink } from '@kit.ArkUI';", + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 2, + "endLine": 22, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, StorageLink, LocalStorageLink } from '@kit.ArkUI';", + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 4, + "endLine": 25, + "endColumn": 15, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, StorageLink, LocalStorageLink } from '@kit.ArkUI';", + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"StorageLink\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 4, + "endLine": 26, + "endColumn": 20, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, StorageLink, LocalStorageLink } from '@kit.ArkUI';", + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"LocalStorageLink\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Entry, Component, StorageLink, LocalStorageLink } from '@kit.ArkUI';", + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.args.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.json similarity index 94% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.args.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.json index 4acc088d1da62353e56ced57f16b342de413cb78..ca88f857e960b437dcf767c0ac40be998c8f1236 100644 --- a/ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.args.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.json @@ -13,7 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "mode": { - "arkts2": "" - } + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..15f5527cbfb4dc05f4e52960271c317cb6b3dedc --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.ets @@ -0,0 +1,43 @@ +/* + * 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 { PropRef, StoragePropRef, LocalStoragePropRef } from '@kit.ArkUI'; + +import { Entry, Component, StorageLink, LocalStorageLink } from '@kit.ArkUI'; + +class User { + name: string = "" + age: number = 0.0 +} + +@Entry +@Component +struct FatherComponent { + @PropRef user1: User = new User() + @StorageLink("user2") user2: User = new User() + @LocalStorageLink("user3") user3: User = new User() + + build() { + } +} + +@Component +struct ChildComponent { + @StoragePropRef user2: User = new User() + @LocalStoragePropRef user3: User = new User() + + build() { + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/debugger_statememt.ets.autofix.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json similarity index 52% rename from ets2panda/linter/test/main/debugger_statememt.ets.autofix.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json index 6c9d73e3d1b95d4073a99e0e9c4d36a103b55faa..671d92eb7693ce9f9e8b63b43c7e0325247a9ff9 100644 --- a/ets2panda/linter/test/main/debugger_statememt.ets.autofix.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_1.ets.migrate.json @@ -15,37 +15,33 @@ ], "result": [ { - "line": 16, - "column": 1, - "endLine": 16, - "endColumn": 10, - "problem": "DebuggerStatement", - "autofix": [ - { - "start": 605, - "end": 614, - "replacementText": "specialAutofixLib.debugger();" - } - ], + "line": 28, + "column": 3, + "endLine": 28, + "endColumn": 11, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 3, + "endLine": 38, + "endColumn": 18, + "problem": "DecoratorsNotSupported", "suggest": "", - "rule": "\"debugger\" is not supported (arkts-no-debugger-stmt)", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" }, { - "line": 19, + "line": 39, "column": 3, - "endLine": 19, - "endColumn": 12, - "problem": "DebuggerStatement", - "autofix": [ - { - "start": 633, - "end": 642, - "replacementText": "specialAutofixLib.debugger();" - } - ], + "endLine": 39, + "endColumn": 23, + "problem": "DecoratorsNotSupported", "suggest": "", - "rule": "\"debugger\" is not supported (arkts-no-debugger-stmt)", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets.args.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets.args.json similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_1.ets.args.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets.args.json diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets.arkts2.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets.arkts2.json similarity index 84% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets.arkts2.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets.arkts2.json index 791b77c85e61b4463b108d16f15083fa86c74a2a..4ab5760d4bb94e54af8d359bbce52242bdadaf0f 100644 --- a/ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets.arkts2.json @@ -281,7 +281,7 @@ "endColumn": 26, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -291,7 +291,7 @@ "endColumn": 45, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -301,7 +301,7 @@ "endColumn": 38, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -311,7 +311,7 @@ "endColumn": 38, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -321,7 +321,7 @@ "endColumn": 38, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -331,7 +331,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -341,7 +341,7 @@ "endColumn": 23, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -351,7 +351,7 @@ "endColumn": 23, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -361,7 +361,7 @@ "endColumn": 23, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -371,7 +371,7 @@ "endColumn": 39, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -381,7 +381,7 @@ "endColumn": 60, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -391,7 +391,7 @@ "endColumn": 39, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -401,7 +401,7 @@ "endColumn": 62, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -411,7 +411,7 @@ "endColumn": 39, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -421,7 +421,7 @@ "endColumn": 71, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"AppStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -431,7 +431,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -441,7 +441,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -451,7 +451,7 @@ "endColumn": 35, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -461,7 +461,7 @@ "endColumn": 46, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"SubscribedAbstractProperty\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets.json similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_2.ets.json diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets.args.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets.args.json similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_2.ets.args.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets.args.json diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.arkts2.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets.arkts2.json similarity index 96% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.arkts2.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets.arkts2.json index 07fee6d056caec554e2c8a300304c1c9489eac6e..17b93fa546489901b9664d84a0bd78e904ab184f 100644 --- a/ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.arkts2.json +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets.arkts2.json @@ -351,7 +351,7 @@ "endColumn": 26, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -361,7 +361,7 @@ "endColumn": 45, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"LocalStorage\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -371,7 +371,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -381,7 +381,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets.json similarity index 100% rename from ets2panda/linter/test/main/prop_decorator_and_interfaces_3.ets.json rename to ets2panda/linter/test/main/prop_decorators_and_interfaces_3.ets.json diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f8c44b2269e78ee952f21c78af4d88ffe23815e --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets @@ -0,0 +1,108 @@ +/* + * 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. + */ + +interface ChildComponentOptions { + count: number; +} + +@Component +struct SuperComponent1 { + @State countOptions: ChildComponentOptions = { count: 0 } + + build() { + Column() { + ChildComponent1({ options1: this.countOptions }) + Text(`${this.countOptions.count}`) + } + } +} + +@Component +struct SuperComponent2 { + @State countOptions: ChildComponentOptions = { count: 0 } + + build() { + Column() { + ChildComponent2({ options2: this.countOptions }) + Text(`${this.countOptions.count}`) + } + } +} + +@Component +struct SuperComponent3 { + @State countOptions: ChildComponentOptions = { count: 0 } + + build() { + Column() { + ChildComponent3({ options3: this.countOptions }) + Text(`${this.countOptions.count}`) + } + } +} + +@Component +struct ChildComponent1 { + @Prop options1: ChildComponentOptions; + + build() { + Row() { + Text(`${this.options1.count}`) + Blank() + Button('+').onClick(() => { + this.options1.count++; + }) + Button('-').onClick(() => { + this.options1.count--; + }) + } + } +} + +@Component +struct ChildComponent2 { + @Prop options2: ChildComponentOptions; + + build() { + Row() { + Text(`${this.options2.count}`) + Blank() + Button('change1').onClick(() => { + this.options2.count = 1; + }) + Button('change2').onClick(() => { + this.options2.count = 1; + }) + } + } +} + +@Component +struct ChildComponent3 { + @Prop options3: ChildComponentOptions; + + build() { + Row() { + Text(`${this.options3.count}`) + Blank() + Button('+').onClick(() => { + ++this.options3.count; + }) + Button('-').onClick(() => { + --this.options3.count; + }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.args.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..ee0734c0fc5b9a918bfdd7245e6ef1efeb8ad7e6 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.args.json @@ -0,0 +1,21 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.arkts2.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..5864532002ce25ed54f6381dd9a67d1ec5f43100 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.arkts2.json @@ -0,0 +1,428 @@ +{ + "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": 57, + "endLine": 22, + "endColumn": 58, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 25, + "endLine": 26, + "endColumn": 52, + "problem": "PropNeedCallMethodForDeepCopy", + "suggest": "", + "rule": "Parameters decorated with \"@Prop\" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 57, + "endLine": 34, + "endColumn": 58, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 25, + "endLine": 38, + "endColumn": 52, + "problem": "PropNeedCallMethodForDeepCopy", + "suggest": "", + "rule": "Parameters decorated with \"@Prop\" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 57, + "endLine": 46, + "endColumn": 58, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 25, + "endLine": 50, + "endColumn": 52, + "problem": "PropNeedCallMethodForDeepCopy", + "suggest": "", + "rule": "Parameters decorated with \"@Prop\" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 3, + "endLine": 58, + "endColumn": 41, + "problem": "PropDecoratorNotSupported", + "suggest": "", + "rule": "\"@Prop\" decorator is not supported (arkui-no-prop-decorator)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 3, + "endLine": 76, + "endColumn": 41, + "problem": "PropDecoratorNotSupported", + "suggest": "", + "rule": "\"@Prop\" decorator is not supported (arkui-no-prop-decorator)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 31, + "endLine": 83, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 31, + "endLine": 86, + "endColumn": 32, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 3, + "endLine": 94, + "endColumn": 41, + "problem": "PropDecoratorNotSupported", + "suggest": "", + "rule": "\"@Prop\" decorator is not supported (arkui-no-prop-decorator)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 4, + "endLine": 34, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 7, + "endLine": 39, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 2, + "endLine": 44, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 4, + "endLine": 46, + "endColumn": 9, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 5, + "endLine": 49, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 7, + "endLine": 51, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 2, + "endLine": 56, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 5, + "endLine": 61, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 7, + "endLine": 62, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 7, + "endLine": 63, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 7, + "endLine": 64, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 7, + "endLine": 67, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 2, + "endLine": 74, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 5, + "endLine": 79, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 7, + "endLine": 80, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 7, + "endLine": 81, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 7, + "endLine": 82, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 7, + "endLine": 85, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 2, + "endLine": 92, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 5, + "endLine": 97, + "endColumn": 8, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 7, + "endLine": 98, + "endColumn": 11, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 7, + "endLine": 99, + "endColumn": 12, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 7, + "endLine": 100, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13, + "problem": "UIInterfaceImport", + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..2de9a369ef12767ca41c76e033d87cd1f4c16cd4 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.autofix.json @@ -0,0 +1,846 @@ +{ + "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": 57, + "endLine": 22, + "endColumn": 58, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 751, + "end": 752, + "replacementText": "0.0", + "line": 22, + "column": 57, + "endLine": 22, + "endColumn": 58 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 25, + "endLine": 26, + "endColumn": 52, + "problem": "PropNeedCallMethodForDeepCopy", + "suggest": "", + "rule": "Parameters decorated with \"@Prop\" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 57, + "endLine": 34, + "endColumn": 58, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 984, + "end": 985, + "replacementText": "0.0", + "line": 34, + "column": 57, + "endLine": 34, + "endColumn": 58 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 25, + "endLine": 38, + "endColumn": 52, + "problem": "PropNeedCallMethodForDeepCopy", + "suggest": "", + "rule": "Parameters decorated with \"@Prop\" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 57, + "endLine": 46, + "endColumn": 58, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1217, + "end": 1218, + "replacementText": "0.0", + "line": 46, + "column": 57, + "endLine": 46, + "endColumn": 58 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 25, + "endLine": 50, + "endColumn": 52, + "problem": "PropNeedCallMethodForDeepCopy", + "suggest": "", + "rule": "Parameters decorated with \"@Prop\" need to call the specific method when receiving data to ensure deep copy of the data (arkui-prop-need-call-method-for-deep-copy)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 3, + "endLine": 58, + "endColumn": 41, + "problem": "PropDecoratorNotSupported", + "autofix": [ + { + "start": 1396, + "end": 1401, + "replacementText": "@PropRef", + "line": 58, + "column": 3, + "endLine": 58, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "\"@Prop\" decorator is not supported (arkui-no-prop-decorator)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 3, + "endLine": 76, + "endColumn": 41, + "problem": "PropDecoratorNotSupported", + "autofix": [ + { + "start": 1710, + "end": 1715, + "replacementText": "@PropRef", + "line": 76, + "column": 3, + "endLine": 76, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "\"@Prop\" decorator is not supported (arkui-no-prop-decorator)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 31, + "endLine": 83, + "endColumn": 32, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1895, + "end": 1896, + "replacementText": "1.0", + "line": 83, + "column": 31, + "endLine": 83, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 31, + "endLine": 86, + "endColumn": 32, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1977, + "end": 1978, + "replacementText": "1.0", + "line": 86, + "column": 31, + "endLine": 86, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 3, + "endLine": 94, + "endColumn": 41, + "problem": "PropDecoratorNotSupported", + "autofix": [ + { + "start": 2040, + "end": 2045, + "replacementText": "@PropRef", + "line": 94, + "column": 3, + "endLine": 94, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "\"@Prop\" decorator is not supported (arkui-no-prop-decorator)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 2, + "endLine": 20, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 4, + "endLine": 22, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 7, + "endLine": 27, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 2, + "endLine": 32, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 4, + "endLine": 34, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 7, + "endLine": 39, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 2, + "endLine": 44, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 4, + "endLine": 46, + "endColumn": 9, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 5, + "endLine": 49, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 7, + "endLine": 51, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 2, + "endLine": 56, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 5, + "endLine": 61, + "endColumn": 8, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 7, + "endLine": 62, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 7, + "endLine": 63, + "endColumn": 12, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 7, + "endLine": 64, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 7, + "endLine": 67, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 2, + "endLine": 74, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 5, + "endLine": 79, + "endColumn": 8, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 7, + "endLine": 80, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 7, + "endLine": 81, + "endColumn": 12, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 7, + "endLine": 82, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 7, + "endLine": 85, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 92, + "column": 2, + "endLine": 92, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 5, + "endLine": 97, + "endColumn": 8, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Row\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 7, + "endLine": 98, + "endColumn": 11, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 7, + "endLine": 99, + "endColumn": 12, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Blank\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 7, + "endLine": 100, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13, + "problem": "UIInterfaceImport", + "autofix": [ + { + "start": 603, + "end": 603, + "replacementText": "\n\nimport { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI';", + "line": 103, + "column": 7, + "endLine": 103, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.migrate.ets b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..718335619754d105fad853e8326ad973d9fe62c2 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.migrate.ets @@ -0,0 +1,112 @@ +/* + * 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 { PropRef } from '@kit.ArkUI'; + +import { Component, State, Column, Text, Row, Blank, Button } from '@kit.ArkUI'; + +interface ChildComponentOptions { + count: number; +} + +@Component +struct SuperComponent1 { + @State countOptions: ChildComponentOptions = { count: 0.0 } + + build() { + Column() { + ChildComponent1({ options1: this.countOptions }) + Text(`${this.countOptions.count}`) + } + } +} + +@Component +struct SuperComponent2 { + @State countOptions: ChildComponentOptions = { count: 0.0 } + + build() { + Column() { + ChildComponent2({ options2: this.countOptions }) + Text(`${this.countOptions.count}`) + } + } +} + +@Component +struct SuperComponent3 { + @State countOptions: ChildComponentOptions = { count: 0.0 } + + build() { + Column() { + ChildComponent3({ options3: this.countOptions }) + Text(`${this.countOptions.count}`) + } + } +} + +@Component +struct ChildComponent1 { + @PropRef options1: ChildComponentOptions; + + build() { + Row() { + Text(`${this.options1.count}`) + Blank() + Button('+').onClick(() => { + this.options1.count++; + }) + Button('-').onClick(() => { + this.options1.count--; + }) + } + } +} + +@Component +struct ChildComponent2 { + @PropRef options2: ChildComponentOptions; + + build() { + Row() { + Text(`${this.options2.count}`) + Blank() + Button('change1').onClick(() => { + this.options2.count = 1.0; + }) + Button('change2').onClick(() => { + this.options2.count = 1.0; + }) + } + } +} + +@Component +struct ChildComponent3 { + @PropRef options3: ChildComponentOptions; + + build() { + Row() { + Text(`${this.options3.count}`) + Blank() + Button('+').onClick(() => { + ++this.options3.count; + }) + Button('-').onClick(() => { + --this.options3.count; + }) + } + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.migrate.json b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..e9031d32bc8823d5f098f69a9f3fe7409f973de1 --- /dev/null +++ b/ets2panda/linter/test/main/prop_decorators_and_interfaces_4.ets.migrate.json @@ -0,0 +1,78 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 62, + "column": 3, + "endLine": 62, + "endColumn": 11, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 3, + "endLine": 80, + "endColumn": 11, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 3, + "endLine": 98, + "endColumn": 11, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 12, + "endLine": 62, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Property 'options1' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'options1' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 80, + "column": 12, + "endLine": 80, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Property 'options2' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'options2' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + }, + { + "line": 98, + "column": 12, + "endLine": 98, + "endColumn": 20, + "problem": "StrictDiagnostic", + "suggest": "Property 'options3' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'options3' has no initializer and is not definitely assigned in the constructor.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/property_access_by_index.ets b/ets2panda/linter/test/main/property_access_by_index.ets index a19d0154802a6a02c685d077909c66a95a19c687..6424bdfec86f3cf4c1a962d3c841a9f8de416604 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets +++ b/ets2panda/linter/test/main/property_access_by_index.ets @@ -182,3 +182,15 @@ class MyClass extends collections.BitVector { } } } + +class AA { + i: number = 1.0; + func(b: number) {} +} +let a: object = new AA(); +let b: AA = new AA(); +b[i] = 1.0; +a["i"] = 2.0; +(b as object)["i"] = 2.0; +(b as object)["func"](1.0); +(b as object)["func1"](1.0); diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.args.json b/ets2panda/linter/test/main/property_access_by_index.ets.args.json index 7341e330faa243cfdd4795226601488b62c2f729..25a9f93078835dbe3acbe3159154fe49f5a70b35 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.args.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.args.json @@ -14,8 +14,8 @@ "limitations under the License." ], "mode": { - "autofix": "", + "autofix": "--arkts-2", "arkts2": "", - "migrate": "" + "migrate": "--arkts-2" } } diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json index 8bdc1c6d5d3ea74b51d8fa0e7c98ba16717df53e..a5f04e6564ab3a1cda9b1fd1d34d5edb3ea4016c 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.arkts2.json @@ -124,6 +124,36 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 37, + "column": 1, + "endLine": 37, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 1, + "endLine": 38, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 1, + "endLine": 39, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 41, "column": 7, @@ -494,6 +524,196 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 1, + "endLine": 73, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 1, + "endLine": 74, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 1, + "endLine": 76, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 1, + "endLine": 77, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 1, + "endLine": 78, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 1, + "endLine": 79, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 1, + "endLine": 80, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 1, + "endLine": 82, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 1, + "endLine": 83, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 1, + "endLine": 84, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 1, + "endLine": 85, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 1, + "endLine": 97, + "endColumn": 18, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 1, + "endLine": 98, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, { "line": 105, "column": 31, @@ -674,6 +894,16 @@ "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" }, + { + "line": 176, + "column": 1, + "endLine": 176, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, { "line": 177, "column": 23, @@ -723,6 +953,56 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 192, + "column": 1, + "endLine": 192, + "endColumn": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 193, + "column": 1, + "endLine": 193, + "endColumn": 7, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 194, + "column": 1, + "endLine": 194, + "endColumn": 19, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 195, + "column": 1, + "endLine": 195, + "endColumn": 22, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 196, + "column": 1, + "endLine": 196, + "endColumn": 23, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json index f1ca92fec988d00ac08f6046bf68933a27b0ca0a..5125535ce1c107cda2c8ffa1e786cff776c37189 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json @@ -14,6 +14,27 @@ "limitations under the License." ], "result": [ + { + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 21, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 662, + "end": 713, + "replacementText": "", + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, { "line": 22, "column": 3, @@ -34,6 +55,256 @@ "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" }, + { + "line": 33, + "column": 5, + "endLine": 33, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1158, + "end": 1176, + "replacementText": "ar1: number[] = [1, 2, 3, 4]", + "line": 33, + "column": 5, + "endLine": 33, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 12, + "endLine": 33, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1165, + "end": 1166, + "replacementText": "1.0", + "line": 33, + "column": 12, + "endLine": 33, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 15, + "endLine": 33, + "endColumn": 16, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1168, + "end": 1169, + "replacementText": "2.0", + "line": 33, + "column": 15, + "endLine": 33, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 18, + "endLine": 33, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1171, + "end": 1172, + "replacementText": "3.0", + "line": 33, + "column": 18, + "endLine": 33, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 21, + "endLine": 33, + "endColumn": 22, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1174, + "end": 1175, + "replacementText": "4.0", + "line": 33, + "column": 21, + "endLine": 33, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 12, + "endLine": 34, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1189, + "end": 1190, + "replacementText": "1.0", + "line": 34, + "column": 12, + "endLine": 34, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 20, + "endLine": 34, + "endColumn": 21, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1197, + "end": 1198, + "replacementText": "3.0", + "line": 34, + "column": 20, + "endLine": 34, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 34, + "column": 23, + "endLine": 34, + "endColumn": 24, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1200, + "end": 1201, + "replacementText": "4.0", + "line": 34, + "column": 23, + "endLine": 34, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 1, + "endLine": 37, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 1, + "endLine": 38, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 1, + "endLine": 39, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 7, + "endLine": 41, + "endColumn": 24, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1260, + "end": 1277, + "replacementText": "r0: number = [1, 2, 3][1]", + "line": 41, + "column": 7, + "endLine": 41, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 5, + "endLine": 42, + "endColumn": 25, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1283, + "end": 1303, + "replacementText": "r1: number = [1, 2, 3, 4][0]", + "line": 42, + "column": 5, + "endLine": 42, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 3, + "endLine": 46, + "endColumn": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, { "line": 50, "column": 3, @@ -44,6 +315,405 @@ "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" }, + { + "line": 53, + "column": 5, + "endLine": 53, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1422, + "end": 1436, + "replacementText": "array1: number[] = [0, 1]", + "line": 53, + "column": 5, + "endLine": 53, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 15, + "endLine": 53, + "endColumn": 16, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1432, + "end": 1433, + "replacementText": "0.0", + "line": 53, + "column": 15, + "endLine": 53, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 17, + "endLine": 53, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1434, + "end": 1435, + "replacementText": "1.0", + "line": 53, + "column": 17, + "endLine": 53, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 25, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1441, + "end": 1461, + "replacementText": "array2: number[] = [1, 2, 3, 4, 5]", + "line": 54, + "column": 5, + "endLine": 54, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 15, + "endLine": 54, + "endColumn": 16, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1451, + "end": 1452, + "replacementText": "1.0", + "line": 54, + "column": 15, + "endLine": 54, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 17, + "endLine": 54, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1453, + "end": 1454, + "replacementText": "2.0", + "line": 54, + "column": 17, + "endLine": 54, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 19, + "endLine": 54, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1455, + "end": 1456, + "replacementText": "3.0", + "line": 54, + "column": 19, + "endLine": 54, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 21, + "endLine": 54, + "endColumn": 22, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1457, + "end": 1458, + "replacementText": "4.0", + "line": 54, + "column": 21, + "endLine": 54, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 23, + "endLine": 54, + "endColumn": 24, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1459, + "end": 1460, + "replacementText": "5.0", + "line": 54, + "column": 23, + "endLine": 54, + "endColumn": 24 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 25, + "endLine": 55, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1486, + "end": 1487, + "replacementText": "1.0", + "line": 55, + "column": 25, + "endLine": 55, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 27, + "endLine": 55, + "endColumn": 28, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1488, + "end": 1489, + "replacementText": "2.0", + "line": 55, + "column": 27, + "endLine": 55, + "endColumn": 28 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 29, + "endLine": 55, + "endColumn": 30, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1490, + "end": 1491, + "replacementText": "3.0", + "line": 55, + "column": 29, + "endLine": 55, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 31, + "endLine": 55, + "endColumn": 32, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1492, + "end": 1493, + "replacementText": "4.0", + "line": 55, + "column": 31, + "endLine": 55, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 33, + "endLine": 55, + "endColumn": 34, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1494, + "end": 1495, + "replacementText": "5.0", + "line": 55, + "column": 33, + "endLine": 55, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 30, + "endLine": 56, + "endColumn": 31, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1526, + "end": 1527, + "replacementText": "1.0", + "line": 56, + "column": 30, + "endLine": 56, + "endColumn": 31 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 32, + "endLine": 56, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1528, + "end": 1529, + "replacementText": "2.0", + "line": 56, + "column": 32, + "endLine": 56, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 34, + "endLine": 56, + "endColumn": 35, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1530, + "end": 1531, + "replacementText": "3.0", + "line": 56, + "column": 34, + "endLine": 56, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 36, + "endLine": 56, + "endColumn": 37, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1532, + "end": 1533, + "replacementText": "4.0", + "line": 56, + "column": 36, + "endLine": 56, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 38, + "endLine": 56, + "endColumn": 39, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1534, + "end": 1535, + "replacementText": "5.0", + "line": 56, + "column": 38, + "endLine": 56, + "endColumn": 39 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 57, "column": 5, @@ -54,6 +724,541 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 57, + "column": 14, + "endLine": 57, + "endColumn": 27, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 24, + "endLine": 57, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1560, + "end": 1562, + "replacementText": "10.0", + "line": 57, + "column": 24, + "endLine": 57, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 58, + "column": 28, + "endLine": 58, + "endColumn": 30, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1591, + "end": 1593, + "replacementText": "10.0", + "line": 58, + "column": 28, + "endLine": 58, + "endColumn": 30 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 29, + "endLine": 59, + "endColumn": 31, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1623, + "end": 1625, + "replacementText": "10.0", + "line": 59, + "column": 29, + "endLine": 59, + "endColumn": 31 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 36, + "endLine": 60, + "endColumn": 38, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1662, + "end": 1664, + "replacementText": "10.0", + "line": 60, + "column": 36, + "endLine": 60, + "endColumn": 38 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 29, + "endLine": 61, + "endColumn": 31, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1694, + "end": 1696, + "replacementText": "10.0", + "line": 61, + "column": 29, + "endLine": 61, + "endColumn": 31 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 31, + "endLine": 62, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1728, + "end": 1730, + "replacementText": "10.0", + "line": 62, + "column": 31, + "endLine": 62, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 30, + "endLine": 63, + "endColumn": 32, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1761, + "end": 1763, + "replacementText": "10.0", + "line": 63, + "column": 30, + "endLine": 63, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 31, + "endLine": 64, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1795, + "end": 1797, + "replacementText": "10.0", + "line": 64, + "column": 31, + "endLine": 64, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 32, + "endLine": 65, + "endColumn": 34, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1830, + "end": 1832, + "replacementText": "10.0", + "line": 65, + "column": 32, + "endLine": 65, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 66, + "column": 32, + "endLine": 66, + "endColumn": 34, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1865, + "end": 1867, + "replacementText": "10.0", + "line": 66, + "column": 32, + "endLine": 66, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 67, + "column": 33, + "endLine": 67, + "endColumn": 35, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1901, + "end": 1903, + "replacementText": "10.0", + "line": 67, + "column": 33, + "endLine": 67, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 34, + "endLine": 68, + "endColumn": 36, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1938, + "end": 1940, + "replacementText": "10.0", + "line": 68, + "column": 34, + "endLine": 68, + "endColumn": 36 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 1, + "endLine": 73, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 1, + "endLine": 74, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 1, + "endLine": 76, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 1, + "endLine": 77, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 1, + "endLine": 78, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 1, + "endLine": 79, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 1, + "endLine": 80, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 1, + "endLine": 82, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 1, + "endLine": 83, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 1, + "endLine": 84, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 1, + "endLine": 85, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 1, + "endLine": 97, + "endColumn": 18, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 1, + "endLine": 98, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 31, + "endLine": 105, + "endColumn": 32, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2388, + "end": 2389, + "replacementText": "1.0", + "line": 105, + "column": 31, + "endLine": 105, + "endColumn": 32 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 33, + "endLine": 105, + "endColumn": 34, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2390, + "end": 2391, + "replacementText": "2.0", + "line": 105, + "column": 33, + "endLine": 105, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 35, + "endLine": 105, + "endColumn": 36, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2392, + "end": 2393, + "replacementText": "3.0", + "line": 105, + "column": 35, + "endLine": 105, + "endColumn": 36 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 24, + "endLine": 107, + "endColumn": 39, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 24, + "endLine": 107, + "endColumn": 39, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, { "line": 108, "column": 5, @@ -64,6 +1269,46 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 108, + "column": 17, + "endLine": 108, + "endColumn": 40, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 15, + "endLine": 112, + "endColumn": 38, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 20, + "endLine": 117, + "endColumn": 35, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 20, + "endLine": 117, + "endColumn": 35, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, { "line": 118, "column": 5, @@ -74,6 +1319,36 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 118, + "column": 15, + "endLine": 118, + "endColumn": 36, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 13, + "endLine": 121, + "endColumn": 34, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 12, + "endLine": 139, + "endColumn": 31, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, { "line": 159, "column": 3, @@ -83,6 +1358,234 @@ "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" + }, + { + "line": 172, + "column": 1, + "endLine": 172, + "endColumn": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 173, + "column": 1, + "endLine": 173, + "endColumn": 13, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 174, + "column": 1, + "endLine": 174, + "endColumn": 13, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 1, + "endLine": 176, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "autofix": [ + { + "start": 3701, + "end": 3710, + "replacementText": "", + "line": 176, + "column": 1, + "endLine": 176, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, + { + "line": 177, + "column": 23, + "endLine": 177, + "endColumn": 34, + "problem": "NoNeedStdLibSendableContainer", + "autofix": [ + { + "start": 3733, + "end": 3754, + "replacementText": "BitVector", + "line": 177, + "column": 23, + "endLine": 177, + "endColumn": 34 + } + ], + "suggest": "", + "rule": "Sendable containers are not supported (arkts-no-need-stdlib-sendable-containers)", + "severity": "ERROR" + }, + { + "line": 179, + "column": 11, + "endLine": 179, + "endColumn": 12, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3785, + "end": 3786, + "replacementText": "0.0", + "line": 179, + "column": 11, + "endLine": 179, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 180, + "column": 14, + "endLine": 180, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3802, + "end": 3807, + "replacementText": "i: number = 0", + "line": 180, + "column": 14, + "endLine": 180, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 180, + "column": 18, + "endLine": 180, + "endColumn": 19, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3806, + "end": 3807, + "replacementText": "0.0", + "line": 180, + "column": 18, + "endLine": 180, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 181, + "column": 17, + "endLine": 181, + "endColumn": 18, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 3849, + "end": 3850, + "replacementText": "1.0", + "line": 181, + "column": 17, + "endLine": 181, + "endColumn": 18 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 192, + "column": 1, + "endLine": 192, + "endColumn": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 193, + "column": 1, + "endLine": 193, + "endColumn": 7, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 194, + "column": 1, + "endLine": 194, + "endColumn": 19, + "problem": "PropertyAccessByIndex", + "autofix": [ + { + "replacementText": "b.i", + "start": 3992, + "end": 4010, + "line": 194, + "column": 1, + "endLine": 194, + "endColumn": 19 + } + ], + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 195, + "column": 1, + "endLine": 195, + "endColumn": 22, + "problem": "PropertyAccessByIndex", + "autofix": [ + { + "replacementText": "b.func", + "start": 4018, + "end": 4039, + "line": 195, + "column": 1, + "endLine": 195, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 196, + "column": 1, + "endLine": 196, + "endColumn": 23, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.json b/ets2panda/linter/test/main/property_access_by_index.ets.json index f1ca92fec988d00ac08f6046bf68933a27b0ca0a..18153ecebacd4a6737b2d4af02623fe7c41582df 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.json @@ -83,6 +83,16 @@ "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" + }, + { + "line": 192, + "column": 1, + "endLine": 192, + "endColumn": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets index a19d0154802a6a02c685d077909c66a95a19c687..6d696292479ae1de787de6f538bcd47e72cf3c4b 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets @@ -13,7 +13,7 @@ * limitations under the License. */ import {OhosInterface} from './oh_modules/ohos_lib'; -import { collections } from './@arkts.collections'; + // #14071 class A { v: string = ''; @@ -30,16 +30,16 @@ function test() { return GetProperty(a, 'v') + GetProperty(a, 'u'); } -let ar1 = [1, 2, 3, 4]; -let ar2 = [1, '2', 3, 4]; +let ar1: number[] = [1.0, 2.0, 3.0, 4.0]; +let ar2 = [1.0, '2', 3.0, 4.0]; let ar3: number[] = []; ar1[2]; ar2[2]; ar3[2]; -const r0 = [1, 2, 3][1]; -let r1 = [1, 2, 3, 4][0] +const r0: number = [1, 2, 3][1]; +let r1: number = [1, 2, 3, 4][0] let r2 = [1, '2', 3, 4][0] function fobject1(o: object) { @@ -50,22 +50,22 @@ function fobject2(o: Object) { o['k'] } -let array1 = [0,1] -let array2 = [1,2,3,4,5] -let array3: number[] = [1,2,3,4,5] -let array4: Array = [1,2,3,4,5] -let array5 = new Array(10) -let array6 = new Int8Array(10) -let array7 = new Uint8Array(10) -let array8 = new Uint8ClampedArray(10) -let array9 = new Int16Array(10) -let array10 = new Uint16Array(10) -let array11 = new Int32Array(10) -let array12 = new Uint32Array(10) -let array13 = new Float32Array(10) -let array14 = new Float64Array(10) -let array15 = new BigInt64Array(10) -let array16 = new BigUint64Array(10) +let array1: number[] = [0.0, 1.0] +let array2: number[] = [1.0, 2.0, 3.0, 4.0, 5.0] +let array3: number[] = [1.0,2.0,3.0,4.0,5.0] +let array4: Array = [1.0,2.0,3.0,4.0,5.0] +let array5 = new Array(10.0) +let array6 = new Int8Array(10.0) +let array7 = new Uint8Array(10.0) +let array8 = new Uint8ClampedArray(10.0) +let array9 = new Int16Array(10.0) +let array10 = new Uint16Array(10.0) +let array11 = new Int32Array(10.0) +let array12 = new Uint32Array(10.0) +let array13 = new Float32Array(10.0) +let array14 = new Float64Array(10.0) +let array15 = new BigInt64Array(10.0) +let array16 = new BigUint64Array(10.0) array1[0]; array2[0]; @@ -102,7 +102,7 @@ CCCCCCCCC[CCCCCCCCC.KATE] CCCCCCCCC[CCCCCCCCC.BOB] CCCCCCCCC[CCCCCCCCC.ROB] -let arr32 = new Float32Array([1,2,3]) +let arr32 = new Float32Array([1.0,2.0,3.0]) let iter_arr32 = arr32[Symbol.iterator]() let tmp_arr32 = iter_arr32.next().value; @@ -173,12 +173,24 @@ mmap1[1]; mmap2['222']; mmap3["kkr"]; -@Sendable -class MyClass extends collections.BitVector { + +class MyClass extends BitVector { constructor() { - super(0); - for (let i = 0; i < this.length; i++) { - this[i] = 1; + super(0.0); + for (let i: number = 0.0; i < this.length; i++) { + this[i] = 1.0; } } } + +class AA { + i: number = 1.0; + func(b: number) {} +} +let a: object = new AA(); +let b: AA = new AA(); +b[i] = 1.0; +a["i"] = 2.0; +b.i = 2.0; +b.func(1.0); +(b as object)["func1"](1.0); diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json index e700885404cdb3909d85aea7ff974569658ce43f..3f19efdae121bc87fbe1ef5453e2186385ff1420 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.json @@ -34,6 +34,46 @@ "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" }, + { + "line": 37, + "column": 1, + "endLine": 37, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 1, + "endLine": 38, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 1, + "endLine": 39, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 3, + "endLine": 46, + "endColumn": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, { "line": 50, "column": 3, @@ -48,12 +88,232 @@ "line": 57, "column": 5, "endLine": 57, - "endColumn": 27, + "endColumn": 29, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 57, + "column": 14, + "endLine": 57, + "endColumn": 29, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 70, + "column": 1, + "endLine": 70, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 71, + "column": 1, + "endLine": 71, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 72, + "column": 1, + "endLine": 72, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 73, + "column": 1, + "endLine": 73, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 74, + "column": 1, + "endLine": 74, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 75, + "column": 1, + "endLine": 75, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 76, + "column": 1, + "endLine": 76, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 1, + "endLine": 77, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 78, + "column": 1, + "endLine": 78, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 79, + "column": 1, + "endLine": 79, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 1, + "endLine": 80, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 81, + "column": 1, + "endLine": 81, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 82, + "column": 1, + "endLine": 82, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 1, + "endLine": 83, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 84, + "column": 1, + "endLine": 84, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 1, + "endLine": 85, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 1, + "endLine": 97, + "endColumn": 18, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 1, + "endLine": 98, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 24, + "endLine": 107, + "endColumn": 39, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 24, + "endLine": 107, + "endColumn": 39, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, { "line": 108, "column": 5, @@ -64,6 +324,46 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 108, + "column": 17, + "endLine": 108, + "endColumn": 40, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 112, + "column": 15, + "endLine": 112, + "endColumn": 38, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 20, + "endLine": 117, + "endColumn": 35, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 20, + "endLine": 117, + "endColumn": 35, + "problem": "BuiltinSymbolIterator", + "suggest": "", + "rule": "Using \"Symbol.iterator\" is not allowed in this API (arkts-builtin-symbol-iterator)", + "severity": "ERROR" + }, { "line": 118, "column": 5, @@ -74,6 +374,36 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, + { + "line": 118, + "column": 15, + "endLine": 118, + "endColumn": 36, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 13, + "endLine": 121, + "endColumn": 34, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 12, + "endLine": 139, + "endColumn": 31, + "problem": "CreatingPrimitiveTypes", + "suggest": "", + "rule": "Primitive types are normalized with their boxed type (arkts-primitive-type-normalization)", + "severity": "ERROR" + }, { "line": 159, "column": 3, @@ -83,6 +413,76 @@ "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", "severity": "ERROR" + }, + { + "line": 172, + "column": 1, + "endLine": 172, + "endColumn": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 173, + "column": 1, + "endLine": 173, + "endColumn": 13, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 174, + "column": 1, + "endLine": 174, + "endColumn": 13, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 181, + "column": 7, + "endLine": 181, + "endColumn": 14, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 192, + "column": 1, + "endLine": 192, + "endColumn": 5, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 193, + "column": 1, + "endLine": 193, + "endColumn": 7, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 196, + "column": 1, + "endLine": 196, + "endColumn": 23, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/props_by_index.ets b/ets2panda/linter/test/main/props_by_index.ets new file mode 100644 index 0000000000000000000000000000000000000000..63c685415bf91a103d34a61f88715c5016af29df --- /dev/null +++ b/ets2panda/linter/test/main/props_by_index.ets @@ -0,0 +1,50 @@ +/* + * 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. + */ + +enum TEST { + A, + B, + C +} +const arr = ['a', 'b', 'c']; + +const val = TEST[1]; //error +const value: number = TEST.A; +const arrVal = arr[1]; +let a = 1; +let b = 2.3; +let c = "str"; +let d3 = TEST[TEST.A]; +let d4 = TEST[a]; //error +let d5 = TEST[b]; //error +let d2 = TEST['A']; //error +enum E { A, B, C } +console.log(E[E.A]); +function foo(e: E) { + console.log(E[e]); +} +foo(E.B); +console.log(E[2 as E]); +enum Color { Red, Green = 10, Blue } +enum E1 { One = 1, one = 1, oNe = 1 } +console.log(E1[1 as E1]) +let c1: Color = Color.Green; +console.log(c1.toString()) +console.log(Color[c1]); +enum G { + A = 1, + B = 2 +} +console.log(G[G.A]); \ No newline at end of file diff --git a/ets2panda/linter/test/main/prop_name_from_value.ets.args.json b/ets2panda/linter/test/main/props_by_index.ets.args.json similarity index 100% rename from ets2panda/linter/test/main/prop_name_from_value.ets.args.json rename to ets2panda/linter/test/main/props_by_index.ets.args.json diff --git a/ets2panda/linter/test/main/global_this.ets.autofix.json b/ets2panda/linter/test/main/props_by_index.ets.arkts2.json old mode 100755 new mode 100644 similarity index 36% rename from ets2panda/linter/test/main/global_this.ets.autofix.json rename to ets2panda/linter/test/main/props_by_index.ets.arkts2.json index 95eda816e5d4ddfe3cc3a99b095f66fbd32d7e31..31386736eb43f235f80c169c124407627c70cc2d --- a/ets2panda/linter/test/main/global_this.ets.autofix.json +++ b/ets2panda/linter/test/main/props_by_index.ets.arkts2.json @@ -1,6 +1,6 @@ { "copyright": [ - "Copyright (c) 2024-2025 Huawei Device Co., Ltd.", + "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", @@ -15,188 +15,151 @@ ], "result": [ { - "line": 16, - "column": 7, - "endLine": 16, - "endColumn": 18, + "line": 23, + "column": 13, + "endLine": 23, + "endColumn": 20, + "problem": "UnsupportPropNameFromValue", + "suggest": "", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 16, + "endLine": 25, + "endColumn": 22, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 5, + "endLine": 26, + "endColumn": 10, "problem": "NumericSemantics", - "autofix": [ - { - "start": 616, - "end": 627, - "replacementText": "pi: number = 3.1416", - "line": 16, - "column": 7, - "endLine": 16, - "endColumn": 18 - } - ], "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 19, - "column": 7, - "endLine": 19, - "endColumn": 17, - "problem": "GlobalThisError", + "line": 26, + "column": 9, + "endLine": 26, + "endColumn": 10, + "problem": "NumericSemantics", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 21, - "column": 10, - "endLine": 21, - "endColumn": 23, - "problem": "GlobalThisError", - "autofix": [ - { - "start": 700, - "end": 713, - "replacementText": "specialAutofixLib.globalThis.get(\"pi\")", - "line": 21, - "column": 10, - "endLine": 21, - "endColumn": 23 - } - ], + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 12, + "problem": "NumericSemantics", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 24, - "column": 17, - "endLine": 24, - "endColumn": 20, - "problem": "AnyType", + "line": 30, + "column": 10, + "endLine": 30, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", "severity": "ERROR" }, { - "line": 28, - "column": 1, - "endLine": 28, - "endColumn": 21, - "problem": "GlobalThisError", - "autofix": [ - { - "start": 779, - "end": 799, - "replacementText": "specialAutofixLib.globalThis.set(\"abc\", 200)", - "line": 28, - "column": 1, - "endLine": 28, - "endColumn": 21 - } - ], + "line": 31, + "column": 10, + "endLine": 31, + "endColumn": 17, + "problem": "UnsupportPropNameFromValue", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", "severity": "ERROR" }, { - "line": 28, - "column": 18, - "endLine": 28, - "endColumn": 21, + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 19, "problem": "NumericSemantics", - "autofix": [ - { - "start": 796, - "end": 799, - "replacementText": "200.0", - "line": 28, - "column": 18, - "endLine": 28, - "endColumn": 21 - } - ], "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 30, - "column": 7, - "endLine": 30, - "endColumn": 34, - "problem": "AnyType", + "line": 32, + "column": 10, + "endLine": 32, + "endColumn": 19, + "problem": "UnsupportPropNameFromValue", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Enum cannot get member name by member value (arkts-enum-no-props-by-index)", "severity": "ERROR" }, { - "line": 30, - "column": 15, - "endLine": 30, + "line": 40, + "column": 27, + "endLine": 40, "endColumn": 29, - "problem": "GlobalThisError", - "autofix": [ - { - "start": 816, - "end": 830, - "replacementText": "specialAutofixLib.globalThis.get(\"obj\")", - "line": 30, - "column": 15, - "endLine": 30, - "endColumn": 29 - } - ], + "problem": "NumericSemantics", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 32, - "column": 1, - "endLine": 32, - "endColumn": 7, - "problem": "DeleteOperator", + "line": 41, + "column": 17, + "endLine": 41, + "endColumn": 18, + "problem": "NumericSemantics", "suggest": "", - "rule": "\"delete\" operator is not supported (arkts-no-delete)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 32, - "column": 8, - "endLine": 32, + "line": 41, + "column": 26, + "endLine": 41, "endColumn": 27, - "problem": "GlobalThisError", - "autofix": [ - { - "start": 845, - "end": 864, - "replacementText": "specialAutofixLib.globalThis.get(\"property\")", - "line": 32, - "column": 8, - "endLine": 32, - "endColumn": 27 - } - ], + "problem": "NumericSemantics", "suggest": "", - "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 35, + "endLine": 41, + "endColumn": 36, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 34, - "column": 18, - "endLine": 34, - "endColumn": 21, + "line": 47, + "column": 7, + "endLine": 47, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 7, + "endLine": 48, + "endColumn": 8, "problem": "NumericSemantics", - "autofix": [ - { - "start": 884, - "end": 887, - "replacementText": "100.0", - "line": 34, - "column": 18, - "endLine": 34, - "endColumn": 21 - } - ], "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" diff --git a/ets2panda/linter/test/main/props_by_index.ets.json b/ets2panda/linter/test/main/props_by_index.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..ca88f857e960b437dcf767c0ac40be998c8f1236 --- /dev/null +++ b/ets2panda/linter/test/main/props_by_index.ets.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/provide_annotation_1.ets.arkts2.json b/ets2panda/linter/test/main/provide_annotation_1.ets.arkts2.json index a11e915085f45661608340affe7a0f9687cdf9f6..e8bb63999f47ea6908931a670a4e1b089891cb0d 100644 --- a/ets2panda/linter/test/main/provide_annotation_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/provide_annotation_1.ets.arkts2.json @@ -1,6 +1,6 @@ { "copyright": [ - "Copyright (c) 2023-2024 Huawei Device Co., Ltd.", + "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", @@ -41,7 +41,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/provide_annotation_1.ets.autofix.json b/ets2panda/linter/test/main/provide_annotation_1.ets.autofix.json index 499fa5b2964077f05d7b44e759e4cc617cc850c0..16e13e0bf286f80dd14cfe9816ee7952731349f8 100644 --- a/ets2panda/linter/test/main/provide_annotation_1.ets.autofix.json +++ b/ets2panda/linter/test/main/provide_annotation_1.ets.autofix.json @@ -24,7 +24,11 @@ { "start": 727, "end": 744, - "replacementText": "@Provide({ alias: \"value\" })" + "replacementText": "@Provide({ alias: \"value\" })", + "line": 28, + "column": 3, + "endLine": 29, + "endColumn": 17 } ], "suggest": "", @@ -41,7 +45,11 @@ { "start": 830, "end": 864, - "replacementText": "@Provide({ alias: \"value\", allowOverride: true })" + "replacementText": "@Provide({ alias: \"value\", allowOverride: true })", + "line": 38, + "column": 3, + "endLine": 39, + "endColumn": 17 } ], "suggest": "", @@ -58,11 +66,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -75,11 +87,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -92,11 +108,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -109,11 +129,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -126,11 +150,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -143,11 +171,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -160,11 +192,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -177,11 +213,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -194,11 +234,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/provide_annotation_2.ets.arkts2.json b/ets2panda/linter/test/main/provide_annotation_2.ets.arkts2.json index 5683673096519aab356d8c5e39f24523630fc5f8..2b7ce66f0b867689a319db6eeb32f13a0bade09c 100644 --- a/ets2panda/linter/test/main/provide_annotation_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/provide_annotation_2.ets.arkts2.json @@ -21,7 +21,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -31,7 +31,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -41,7 +41,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/provide_annotation_2.ets.autofix.json b/ets2panda/linter/test/main/provide_annotation_2.ets.autofix.json index f828839e124ace4ad3d38b7f2893c16b7f4d09d7..8a98dfc2d892c6967f814466db422009fb1d22f5 100644 --- a/ets2panda/linter/test/main/provide_annotation_2.ets.autofix.json +++ b/ets2panda/linter/test/main/provide_annotation_2.ets.autofix.json @@ -24,11 +24,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -41,11 +45,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -58,11 +66,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -75,11 +87,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -92,11 +108,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -109,11 +129,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -126,11 +150,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -143,11 +171,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Provide\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -160,11 +192,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';" + "replacementText": "\n\nimport { Component, Provide, Column } from '@kit.ArkUI';", + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 11 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets b/ets2panda/linter/test/main/runtime_array_bound.ets index 435c6ac0e6817708630365cdac50f50fdb0b8e78..55402651662922da880b103f075b670737a3ff60 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets +++ b/ets2panda/linter/test/main/runtime_array_bound.ets @@ -86,5 +86,82 @@ newIndex = 22; arr10[newIndex]; +let arr = [0, 1, 2, 3, 4, 5] +for(let i = 0; i < arr.length; i++) { +arr[i] = arr[i] + 1; +} +for(let i = 0; i < arr.length; i++) { +i = 10; +arr[i] = arr[i] + 1; +} + +let arr = [0, 1, 2, 3, 4, 5] +let idx = 2; +if(idx > 0 && idx < arr.length) { +arr[idx] = arr[idx] + 1; +} +if(idx > 0 && idx < arr.length) { +idx = 10; +arr[idx] = arr[idx] + 1; +} + +let arr = [0, 1, 2, 3, 4, 5] +let idx = 0; +while(idx > 0 && idx < arr.length) { +arr[idx] = arr[idx] + 1; +idx++; +idx = 10; +} +while(idx > 0 && idx < arr.length) { +idx = 10; +arr[idx] = arr[idx] + 1; +} + +let arr = [0, 1, 2, 3, 4, 5] +let idx = 0; +arr[idx]; +arr[10]; +if (arr.length > 10) { +arr[10] = 10; +} + +function foo():int{ +return 1; +} +arr[44/3]; +arr[foo()]; +arr[()=>{return 1}]; +if(arr.length > foo()) { +arr[foo()]; +} +if(arr.length > 44/3) { +arr[4*4/3]; +} + +let arr1:number[] = [1, 1.5,45,2] + +function foo(i:number):number{ + return i; +} + +arr1[3*5] = 23; +arr1[parseInt("16")] = 23; +arr1[foo(16)] = 23 + +let arr1:number[] = [1, 1.5,45,2] + +arr1[Number.MAX_VALUE] = 23; +arr1[Number.MAX_SAFE_INTEGER] = 23; + +let arr1:number[] = [1, 1.5,45,2] +function foo(i:number):number{ + return i; +} +arr1[(24)] = 23; +arr1[+24] = 23; +enum TE{ + AA = 12 +} +arr1[TE.AA] = 12; diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json b/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json index ee17b482f008213a6ee5cdd32b3dd9d4964579b9..fb3f014d249f2a135971c67e17dd2b25f09385df 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.arkts2.json @@ -144,16 +144,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 29, - "column": 5, - "endLine": 29, - "endColumn": 13, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 28, "column": 10, @@ -184,6 +174,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 32, "column": 22, @@ -224,16 +224,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 34, - "column": 5, - "endLine": 34, - "endColumn": 13, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 33, "column": 10, @@ -254,6 +244,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 37, "column": 22, @@ -304,16 +304,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 40, - "column": 5, - "endLine": 40, - "endColumn": 12, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 39, "column": 10, @@ -374,16 +364,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 45, - "column": 5, - "endLine": 45, - "endColumn": 12, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 44, "column": 10, @@ -414,6 +394,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 45, + "column": 5, + "endLine": 45, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 49, "column": 22, @@ -464,6 +454,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 51, + "column": 5, + "endLine": 51, + "endColumn": 13, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 54, "column": 22, @@ -514,6 +514,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 59, + "column": 1, + "endLine": 59, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 61, "column": 22, @@ -584,16 +594,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 67, - "column": 1, - "endLine": 67, - "endColumn": 12, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 69, "column": 22, @@ -634,16 +634,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 71, - "column": 5, - "endLine": 71, - "endColumn": 16, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 70, "column": 19, @@ -704,16 +694,6 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 76, - "column": 5, - "endLine": 76, - "endColumn": 10, - "problem": "RuntimeArrayCheck", - "suggest": "", - "rule": "Array bound not checked. (arkts-runtime-array-check)", - "severity": "ERROR" - }, { "line": 75, "column": 13, @@ -803,6 +783,1076 @@ "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" + }, + { + "line": 89, + "column": 5, + "endLine": 89, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 12, + "endLine": 89, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 15, + "endLine": 89, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 18, + "endLine": 89, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 21, + "endLine": 89, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 24, + "endLine": 89, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 27, + "endLine": 89, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 9, + "endLine": 90, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 90, + "column": 13, + "endLine": 90, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 19, + "endLine": 91, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 9, + "endLine": 93, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 93, + "column": 13, + "endLine": 93, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 5, + "endLine": 94, + "endColumn": 7, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 1, + "endLine": 95, + "endColumn": 7, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 10, + "endLine": 95, + "endColumn": 16, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 19, + "endLine": 95, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 5, + "endLine": 98, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 12, + "endLine": 98, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 15, + "endLine": 98, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 18, + "endLine": 98, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 21, + "endLine": 98, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 24, + "endLine": 98, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 27, + "endLine": 98, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 5, + "endLine": 99, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 11, + "endLine": 99, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 10, + "endLine": 100, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 23, + "endLine": 101, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 10, + "endLine": 103, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 104, + "column": 7, + "endLine": 104, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 1, + "endLine": 105, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 12, + "endLine": 105, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 23, + "endLine": 105, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 5, + "endLine": 108, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 12, + "endLine": 108, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 15, + "endLine": 108, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 18, + "endLine": 108, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 21, + "endLine": 108, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 24, + "endLine": 108, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 108, + "column": 27, + "endLine": 108, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 5, + "endLine": 109, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 11, + "endLine": 109, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 110, + "column": 13, + "endLine": 110, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 23, + "endLine": 111, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 7, + "endLine": 113, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 115, + "column": 13, + "endLine": 115, + "endColumn": 14, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 116, + "column": 7, + "endLine": 116, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 1, + "endLine": 117, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 12, + "endLine": 117, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 23, + "endLine": 117, + "endColumn": 24, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 5, + "endLine": 120, + "endColumn": 29, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 12, + "endLine": 120, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 15, + "endLine": 120, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 18, + "endLine": 120, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 21, + "endLine": 120, + "endColumn": 22, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 24, + "endLine": 120, + "endColumn": 25, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 120, + "column": 27, + "endLine": 120, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 5, + "endLine": 121, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 11, + "endLine": 121, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 122, + "column": 1, + "endLine": 122, + "endColumn": 9, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 1, + "endLine": 123, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 124, + "column": 18, + "endLine": 124, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 1, + "endLine": 125, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 11, + "endLine": 125, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 1, + "endLine": 130, + "endColumn": 2, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 129, + "column": 8, + "endLine": 129, + "endColumn": 9, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 1, + "endLine": 132, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 5, + "endLine": 132, + "endColumn": 9, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 133, + "column": 1, + "endLine": 133, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 1, + "endLine": 134, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 5, + "endLine": 134, + "endColumn": 19, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 1, + "endLine": 136, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 17, + "endLine": 138, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 20, + "endLine": 138, + "endColumn": 21, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 1, + "endLine": 139, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 139, + "column": 5, + "endLine": 139, + "endColumn": 10, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 22, + "endLine": 142, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 29, + "endLine": 142, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 32, + "endLine": 142, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 1, + "endLine": 146, + "endColumn": 2, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 1, + "endLine": 148, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 13, + "endLine": 148, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 1, + "endLine": 149, + "endColumn": 21, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 6, + "endLine": 149, + "endColumn": 20, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 149, + "column": 24, + "endLine": 149, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 1, + "endLine": 150, + "endColumn": 14, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 6, + "endLine": 150, + "endColumn": 13, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 17, + "endLine": 150, + "endColumn": 19, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 152, + "column": 22, + "endLine": 152, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 152, + "column": 29, + "endLine": 152, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 152, + "column": 32, + "endLine": 152, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 1, + "endLine": 154, + "endColumn": 23, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 6, + "endLine": 154, + "endColumn": 22, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 26, + "endLine": 154, + "endColumn": 28, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 155, + "column": 1, + "endLine": 155, + "endColumn": 30, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 155, + "column": 6, + "endLine": 155, + "endColumn": 29, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 155, + "column": 33, + "endLine": 155, + "endColumn": 35, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 22, + "endLine": 157, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 29, + "endLine": 157, + "endColumn": 31, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 32, + "endLine": 157, + "endColumn": 33, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 158, + "column": 1, + "endLine": 160, + "endColumn": 2, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 161, + "column": 1, + "endLine": 161, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 161, + "column": 14, + "endLine": 161, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 1, + "endLine": 162, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 13, + "endLine": 162, + "endColumn": 15, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 164, + "column": 8, + "endLine": 164, + "endColumn": 10, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 166, + "column": 1, + "endLine": 166, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 166, + "column": 15, + "endLine": 166, + "endColumn": 17, + "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/runtime_array_bound.ets.migrate.ets b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.ets index 3ac6cbf3433c32bd8b7df05ca36ab3d12d5ccd01..2d4beff4184f04808d32a5db68bcfc08a248e82c 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.ets +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.ets @@ -86,5 +86,82 @@ newIndex = 22.0; arr10[newIndex as int]; +let arr: number[] = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] +for(let i: number = 0.0; i < arr.length; i++) { +arr[i as int] = arr[i as int] + 1.0; +} +for(let i: number = 0.0; i < arr.length; i++) { +i = 10.0; +arr[i as int] = arr[i as int] + 1.0; +} + +let arr: number[] = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] +let idx: number = 2.0; +if(idx > 0.0 && idx < arr.length) { +arr[idx as int] = arr[idx as int] + 1.0; +} +if(idx > 0.0 && idx < arr.length) { +idx = 10.0; +arr[idx as int] = arr[idx as int] + 1.0; +} + +let arr: number[] = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] +let idx: number = 0.0; +while(idx > 0.0 && idx < arr.length) { +arr[idx as int] = arr[idx as int] + 1.0; +idx++; +idx = 10.0; +} +while(idx > 0.0 && idx < arr.length) { +idx = 10.0; +arr[idx as int] = arr[idx as int] + 1.0; +} + +let arr: number[] = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0] +let idx: number = 0.0; +arr[idx as int]; +arr[10]; +if (arr.length > 10.0) { +arr[10] = 10.0; +} + +function foo():int{ +return 1.0; +} +arr[(44/3) as int]; +arr[foo()]; +arr[()=>{return 1}]; +if(arr.length > foo()) { +arr[foo()]; +} +if(arr.length > 44.0/3.0) { +arr[(4*4/3) as int]; +} + +let arr1:number[] = [1.0, 1.5,45.0,2.0] + +function foo(i:number):number{ + return i; +} + +arr1[3*5] = 23.0; +arr1[parseInt("16") as int] = 23.0; +arr1[foo(16) as int] = 23.0 + +let arr1:number[] = [1.0, 1.5,45.0,2.0] + +arr1[Number.MAX_VALUE as int] = 23.0; +arr1[Number.MAX_SAFE_INTEGER as int] = 23.0; + +let arr1:number[] = [1.0, 1.5,45.0,2.0] +function foo(i:number):number{ + return i; +} +arr1[(24)] = 23.0; +arr1[+24] = 23.0; +enum TE{ + AA = 12.0 +} +arr1[TE.AA] = 12.0; diff --git a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json index 2801165e5d8611744782d6aaaccc8604be228967..a5dcce18b3aeada1bc7e878cffcfa0693bb07477 100644 --- a/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json +++ b/ets2panda/linter/test/main/runtime_array_bound.ets.migrate.json @@ -35,44 +35,154 @@ "severity": "ERROR" }, { - "line": 40, + "line": 51, "column": 5, - "endLine": 40, - "endColumn": 12, + "endLine": 51, + "endColumn": 13, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, { - "line": 67, + "line": 59, "column": 1, - "endLine": 67, - "endColumn": 12, + "endLine": 59, + "endColumn": 9, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, { - "line": 71, - "column": 5, - "endLine": 71, - "endColumn": 16, + "line": 123, + "column": 1, + "endLine": 123, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 1, + "endLine": 125, + "endColumn": 8, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 1, + "endLine": 130, + "endColumn": 2, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 133, + "column": 1, + "endLine": 133, + "endColumn": 11, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, { - "line": 76, + "line": 134, + "column": 1, + "endLine": 134, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 134, "column": 5, - "endLine": 76, + "endLine": 134, + "endColumn": 19, + "problem": "ArrayIndexExprType", + "suggest": "", + "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 1, + "endLine": 136, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 1, + "endLine": 146, + "endColumn": 2, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 1, + "endLine": 148, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 158, + "column": 1, + "endLine": 160, + "endColumn": 2, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 161, + "column": 1, + "endLine": 161, + "endColumn": 11, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 1, + "endLine": 162, "endColumn": 10, "problem": "RuntimeArrayCheck", "suggest": "", "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" + }, + { + "line": 166, + "column": 1, + "endLine": 166, + "endColumn": 12, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" } ] } diff --git a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json index 071dffbe54d7b371f9c3d04390e1ea8bff75b602..f7b6b0c4e8884b33423b670eb5fd2bbea6c10068 100644 --- a/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json +++ b/ets2panda/linter/test/main/stdlib_array.ets.arkts2.json @@ -224,6 +224,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 49, + "column": 12, + "endLine": 49, + "endColumn": 16, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 49, + "column": 19, + "endLine": 49, + "endColumn": 23, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 53, "column": 10, diff --git a/ets2panda/linter/test/main/structural_identity.ets b/ets2panda/linter/test/main/structural_identity.ets index eae4133097d265060b89928949fb24982901a27b..406a7fee8edd059aa887b3e5d1f5e2eed7c97258 100644 --- a/ets2panda/linter/test/main/structural_identity.ets +++ b/ets2panda/linter/test/main/structural_identity.ets @@ -692,4 +692,15 @@ interface goodPerson extends IPerson { sayHello:()=> { return new MyObj2() } - } \ No newline at end of file + } + + async function foo1(): Promise{ + + return new Promise(()=>{ + + }); +} + +function foo2(rule:Record){ + let b:Array = rule['123'] as Array +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/structural_identity.ets.arkts2.json b/ets2panda/linter/test/main/structural_identity.ets.arkts2.json index 1a9ca3c7cfd29082482d0da6d3c02b04726fdfde..89cd070221de4abd16abf56e37ba1cec76a7c1be 100644 --- a/ets2panda/linter/test/main/structural_identity.ets.arkts2.json +++ b/ets2panda/linter/test/main/structural_identity.ets.arkts2.json @@ -64,6 +64,16 @@ "rule": "Structural typing is not supported (arkts-no-structural-typing)", "severity": "ERROR" }, + { + "line": 54, + "column": 3, + "endLine": 54, + "endColumn": 10, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 57, "column": 13, @@ -984,6 +994,26 @@ "rule": "Structural typing is not supported (arkts-no-structural-typing)", "severity": "ERROR" }, + { + "line": 480, + "column": 1, + "endLine": 480, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, + { + "line": 485, + "column": 1, + "endLine": 485, + "endColumn": 10, + "problem": "LimitedStdLibNoSendableDecorator", + "suggest": "", + "rule": "Usage of standard library is restricted(arkts-limited-stdlib-no-sendable-decorator)", + "severity": "ERROR" + }, { "line": 502, "column": 7, @@ -1583,6 +1613,16 @@ "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" + }, + { + "line": 699, + "column": 14, + "endLine": 699, + "endColumn": 21, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json b/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json index d99589819b7c1c733556a8b374aacea208846905..72f2d82336d0211362673a622b13fd07d4a314fa 100644 --- a/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json +++ b/ets2panda/linter/test/main/structural_identity_extended_inheritance.ets.arkts2.json @@ -164,6 +164,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 56, + "column": 1, + "endLine": 56, + "endColumn": 18, + "problem": "ArrayTypeImmutable", + "suggest": "", + "rule": "Array type is immutable in ArkTS1.2 (arkts-array-type-immutable)", + "severity": "ERROR" + }, { "line": 73, "column": 1, diff --git a/ets2panda/linter/test/main/styles_decorator_anon_1.ets.arkts2.json b/ets2panda/linter/test/main/styles_decorator_anon_1.ets.arkts2.json index 3b45c45182eb75c9df74d168b0d611c54f7c2a1c..b63b7b7e89a8470a1623db76b4b672d92f986a4a 100644 --- a/ets2panda/linter/test/main/styles_decorator_anon_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/styles_decorator_anon_1.ets.arkts2.json @@ -61,7 +61,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 31, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_anon_1.ets.autofix.json b/ets2panda/linter/test/main/styles_decorator_anon_1.ets.autofix.json index a6ab4947d57c2baf40d87da6c55d4f162abc4383..caa81eea0f2dc992295b69bd3ed15f37065b669a 100644 --- a/ets2panda/linter/test/main/styles_decorator_anon_1.ets.autofix.json +++ b/ets2panda/linter/test/main/styles_decorator_anon_1.ets.autofix.json @@ -116,7 +116,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -137,7 +137,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -158,7 +158,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -179,7 +179,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -200,7 +200,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_global_1.ets.arkts2.json b/ets2panda/linter/test/main/styles_decorator_global_1.ets.arkts2.json index 8ecdfbedea15ebdf30d7ea7db404c7334023ab05..c5ef980975d08a551a79bfa2e6c03e65297521c5 100644 --- a/ets2panda/linter/test/main/styles_decorator_global_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/styles_decorator_global_1.ets.arkts2.json @@ -91,7 +91,7 @@ "endColumn": 23, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 15, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 17, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 31, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -151,7 +151,7 @@ "endColumn": 18, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -161,7 +161,7 @@ "endColumn": 13, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -171,7 +171,7 @@ "endColumn": 15, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_global_1.ets.autofix.json b/ets2panda/linter/test/main/styles_decorator_global_1.ets.autofix.json index 6327fe8134fd4cac64975f7fb438c94abc393cf6..bbd292d197539bb3e8cb4d68a4175b89dac678cc 100644 --- a/ets2panda/linter/test/main/styles_decorator_global_1.ets.autofix.json +++ b/ets2panda/linter/test/main/styles_decorator_global_1.ets.autofix.json @@ -197,7 +197,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -218,7 +218,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -239,7 +239,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -260,7 +260,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -281,7 +281,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -302,7 +302,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -323,7 +323,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -344,7 +344,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -365,7 +365,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_mix_1.ets.arkts2.json b/ets2panda/linter/test/main/styles_decorator_mix_1.ets.arkts2.json index b0c53b4c8e59d1cb200b077428a1b0c7d7cf5173..8879e846e84502106c3363ab70b8642cf010e359 100644 --- a/ets2panda/linter/test/main/styles_decorator_mix_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/styles_decorator_mix_1.ets.arkts2.json @@ -81,7 +81,7 @@ "endColumn": 27, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -91,7 +91,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -101,7 +101,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +111,7 @@ "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +121,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +131,7 @@ "endColumn": 27, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +141,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -151,7 +151,7 @@ "endColumn": 31, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -161,7 +161,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -171,7 +171,7 @@ "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -181,7 +181,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -191,7 +191,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -201,7 +201,7 @@ "endColumn": 31, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -211,7 +211,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -231,7 +231,7 @@ "endColumn": 33, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -241,7 +241,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -251,7 +251,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -261,7 +261,7 @@ "endColumn": 33, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_mix_1.ets.autofix.json b/ets2panda/linter/test/main/styles_decorator_mix_1.ets.autofix.json index a84810a9e76f91e0a4988d7bb703da2ca2631e99..bca7d3fc19687920c31267362aaf51986ad2d217 100644 --- a/ets2panda/linter/test/main/styles_decorator_mix_1.ets.autofix.json +++ b/ets2panda/linter/test/main/styles_decorator_mix_1.ets.autofix.json @@ -24,7 +24,11 @@ { "start": 605, "end": 673, - "replacementText": "function NormalStyles(instance: CommonMethod): void {\n instance.backgroundColor(Color.Blue);\n}" + "replacementText": "function NormalStyles(instance: CommonMethod): void {\n instance.backgroundColor(Color.Blue);\n}", + "line": 16, + "column": 1, + "endLine": 19, + "endColumn": 2 } ], "suggest": "", @@ -41,7 +45,11 @@ { "start": 765, "end": 830, - "replacementText": "PressedStyles = (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Green);\n };" + "replacementText": "PressedStyles = (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Green);\n };", + "line": 28, + "column": 3, + "endLine": 31, + "endColumn": 4 } ], "suggest": "", @@ -58,7 +66,11 @@ { "start": 912, "end": 1044, - "replacementText": "{\n pressed: this.PressedStyles,\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n },\n normal: NormalStyles\n }" + "replacementText": "{\n pressed: this.PressedStyles,\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n },\n normal: NormalStyles\n }", + "line": 37, + "column": 18, + "endLine": 43, + "endColumn": 6 } ], "suggest": "", @@ -75,7 +87,11 @@ { "start": 1214, "end": 1312, - "replacementText": "{\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n },\n normal: NormalStyles\n }" + "replacementText": "{\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n },\n normal: NormalStyles\n }", + "line": 57, + "column": 18, + "endLine": 62, + "endColumn": 6 } ], "suggest": "", @@ -92,7 +108,11 @@ { "start": 1407, "end": 1514, - "replacementText": "{\n normal: NormalStyles,\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n }\n }" + "replacementText": "{\n normal: NormalStyles,\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n }\n }", + "line": 71, + "column": 20, + "endLine": 76, + "endColumn": 8 } ], "suggest": "", @@ -109,7 +129,11 @@ { "start": 1609, "end": 1716, - "replacementText": "{\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n },\n normal: NormalStyles\n }" + "replacementText": "{\n selected: (instance: CommonMethod): void => {\n instance.backgroundColor(Color.Red);\n },\n normal: NormalStyles\n }", + "line": 85, + "column": 20, + "endLine": 90, + "endColumn": 8 } ], "suggest": "", @@ -126,11 +150,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -143,11 +171,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -160,11 +192,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -177,11 +213,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -194,11 +234,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -211,11 +255,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -228,11 +276,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -245,11 +297,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -262,11 +318,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -279,11 +339,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -296,11 +360,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -313,11 +381,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -330,11 +402,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -347,11 +423,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -364,11 +444,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -381,11 +465,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -398,11 +486,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -415,11 +507,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -432,11 +528,15 @@ { "start": 603, "end": 603, - "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';" + "replacementText": "\n\nimport { CommonMethod, Color, Entry, Component, BuilderParam, Require, Button } from '@kit.ArkUI';", + "line": 87, + "column": 28, + "endLine": 87, + "endColumn": 33 } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json index c4491ce76c85e78ae3744d72560d97a5696cf707..0a96e0ecdc99f3b5d9f2a58a45e720ca8bae21bf 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json @@ -74,6 +74,16 @@ "rule": "\"@Styles\" decorator is not supported (arkui-no-styles-decorator)", "severity": "ERROR" }, + { + "line": 103, + "column": 24, + "endLine": 103, + "endColumn": 37, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, { "line": 105, "column": 3, @@ -101,7 +111,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -111,7 +121,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -121,7 +131,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -131,7 +141,7 @@ "endColumn": 27, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -141,7 +151,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -151,7 +161,7 @@ "endColumn": 28, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -161,7 +171,7 @@ "endColumn": 17, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -171,7 +181,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -181,7 +191,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -191,7 +201,7 @@ "endColumn": 27, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -201,7 +211,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -211,7 +221,7 @@ "endColumn": 16, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +231,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -231,7 +241,7 @@ "endColumn": 27, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -241,7 +251,7 @@ "endColumn": 27, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -251,7 +261,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -261,7 +271,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -271,7 +281,7 @@ "endColumn": 37, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"CustomBuilder\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json index 3575cf7b84094c6a660c67fa31e736c2d582318a..9973d73974d7aa7c7106bafd50794d9b675cd5ab 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json @@ -176,6 +176,16 @@ "rule": "\"@Styles\" decorator is not supported (arkui-no-styles-decorator)", "severity": "ERROR" }, + { + "line": 103, + "column": 24, + "endLine": 103, + "endColumn": 37, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, { "line": 105, "column": 3, @@ -225,7 +235,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -246,7 +256,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -267,7 +277,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -288,7 +298,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -309,7 +319,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -330,7 +340,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -351,7 +361,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -372,7 +382,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Column\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -393,7 +403,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -414,7 +424,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -435,7 +445,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -456,7 +466,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"BuilderParam\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -477,7 +487,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Require\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -498,7 +508,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -519,7 +529,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -540,7 +550,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Button\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -561,7 +571,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -582,7 +592,7 @@ } ], "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"CustomBuilder\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json index 0e17a7dad5ec718d7915c535975cf8c692eecda6..b0daffd23c9959179c3a9632a63638689ccc439f 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 101, + "column": 24, + "endLine": 101, + "endColumn": 37, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, { "line": 105, "column": 26, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json index 7ead10ecf2f79fd56a689b48ec5e545119665be1..1e21ab6ed34665cddbc059e3ea8e8188b5f854ce 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json @@ -34,6 +34,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 101, + "column": 24, + "endLine": 101, + "endColumn": 37, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, { "line": 105, "column": 26, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json index 524d890233577d219c594060a424967e22f1b257..bfbd6bbec990feb4e8b0382f3887eb2ef30bdc25 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json @@ -56,6 +56,16 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 101, + "column": 24, + "endLine": 101, + "endColumn": 37, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, { "line": 105, "column": 26, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json index 0e17a7dad5ec718d7915c535975cf8c692eecda6..b0daffd23c9959179c3a9632a63638689ccc439f 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json @@ -14,6 +14,16 @@ "limitations under the License." ], "result": [ + { + "line": 101, + "column": 24, + "endLine": 101, + "endColumn": 37, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, { "line": 105, "column": 26, diff --git a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json index 5ce55a54ac3b3b4b94d6b10bf24348f2a15a4a24..207e0d7ebf74d0b53f12ef7ce8e7538c45e99f3e 100755 --- a/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json +++ b/ets2panda/linter/test/main/swicth_expr.ets.arkts2.json @@ -174,6 +174,26 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 67, + "column": 7, + "endLine": 67, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 68, + "column": 7, + "endLine": 68, + "endColumn": 8, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 70, "column": 7, diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets index 05ec4e2f14809d6685c63f0ff9c89f60bb817001..8a089d224cfb8b9a91c97b0bb3968b59a2f42082 100644 --- a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets @@ -13,10 +13,54 @@ * limitations under the License. */ 'use static' +import ArrayBuffer,{ taskpool,ArrayList } from '@kit.ArkTS' +import { taskpool as tp } from '@kit.ArkTS' +import * as arkts from '@kit.ArkTS'; +import { task as task7,Task } from './taskpool_deprecated_usages3'; let baseInstance1: BaseClass = new BaseClass(); -let array1 = new Array(); -array1.push(baseInstance1); +let array = new Array(); +array.push(baseInstance1); +let task = new taskpool.Task(testFunc, array, 10); +task.setCloneList(array); //error +task.setTransferList(array); //error + +function testFunc(){} +function test1():void {} + +const array1: number[] =[1] +const transfer: ArrayBuffer[] =[] let task1 = new taskpool.Task(testFunc, array1, 10); -task1.setCloneList(array1); -task1.setTransferList(array1); +task1.setCloneList(array1); //error +task1.setTransferList(transfer); //error + +let task2 = new tp.Task(test1) +task2.setCloneList([]) //error +task2.setCloneList(transfer) //error + +let test3 = new tp.Task(test1) +test3.setCloneList([]) //error +test3.setCloneList([transfer]) //error + +let task4 = new tp.Task(test1) +task4.setTransferList() //error +task4.setTransferList([]) //error +task4.setTransferList(transfer) //error + +let test5 = new tp.Task(test1) +test5.setTransferList() //error +test5.setTransferList([]) //error +test5.setTransferList(transfer) //error + +let task6 = new arkts.taskpool.Task(test1); +task6.setCloneList([]) //error +task6.setCloneList([transfer]) //error + +task7.setCloneList(array1) //error +task7.setTransferList(transfer) //error +new task7.setTransferList(transfer) //error +new task7.setCloneList(array1) //error +new Task(test1).setTransferList(transfer) +new Task(test1).setCloneList(array1) +const task8 = new Task(testFunc); +task8.setCloneList(array1) \ No newline at end of file diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json index 463c82314fe13513cae7fe2a912b6a62eb98b22b..5881b8079dec64adf90ac1344f90305a60f8fd98 100644 --- a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.arkts2.json @@ -14,10 +14,70 @@ "limitations under the License." ], "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 60, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 22, + "endLine": 16, + "endColumn": 30, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, { "line": 17, - "column": 36, + "column": 1, "endLine": 17, + "endColumn": 44, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 44, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 37, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 68, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 36, + "endLine": 21, "endColumn": 45, "problem": "DynamicCtorCall", "suggest": "", @@ -25,9 +85,69 @@ "severity": "ERROR" }, { - "line": 20, + "line": 24, + "column": 5, + "endLine": 24, + "endColumn": 50, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 16, + "endLine": 24, + "endColumn": 29, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 47, + "endLine": 24, + "endColumn": 49, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 6, + "endLine": 25, + "endColumn": 18, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 6, + "endLine": 26, + "endColumn": 21, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 26, + "endLine": 31, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, "column": 5, - "endLine": 20, + "endLine": 33, "endColumn": 52, "problem": "AnyType", "suggest": "", @@ -35,9 +155,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 33, "column": 17, - "endLine": 20, + "endLine": 33, "endColumn": 30, "problem": "DynamicCtorCall", "suggest": "", @@ -45,9 +165,9 @@ "severity": "ERROR" }, { - "line": 20, + "line": 33, "column": 49, - "endLine": 20, + "endLine": 33, "endColumn": 51, "problem": "NumericSemantics", "suggest": "", @@ -55,24 +175,304 @@ "severity": "ERROR" }, { - "line": 21, - "column": 1, - "endLine": 21, - "endColumn": 28, + "line": 34, + "column": 7, + "endLine": 34, + "endColumn": 19, "problem": "SetCloneListDeprecated", "suggest": "", "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", "severity": "ERROR" }, { - "line": 22, - "column": 1, - "endLine": 22, + "line": 35, + "column": 7, + "endLine": 35, + "endColumn": 22, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 37, + "column": 17, + "endLine": 37, + "endColumn": 24, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 7, + "endLine": 38, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 7, + "endLine": 39, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 17, + "endLine": 41, + "endColumn": 24, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 7, + "endLine": 42, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 43, + "column": 7, + "endLine": 43, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 5, + "endLine": 45, "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 17, + "endLine": 45, + "endColumn": 24, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 7, + "endLine": 46, + "endColumn": 22, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 7, + "endLine": 47, + "endColumn": 22, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 7, + "endLine": 48, + "endColumn": 22, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 5, + "endLine": 50, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 17, + "endLine": 50, + "endColumn": 24, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 51, + "column": 7, + "endLine": 51, + "endColumn": 22, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 52, + "column": 7, + "endLine": 52, + "endColumn": 22, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 7, + "endLine": 53, + "endColumn": 22, "problem": "SetTransferListDeprecated", "suggest": "", "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", "severity": "ERROR" + }, + { + "line": 55, + "column": 5, + "endLine": 55, + "endColumn": 43, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 17, + "endLine": 55, + "endColumn": 36, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 56, + "column": 7, + "endLine": 56, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 7, + "endLine": 57, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 59, + "column": 7, + "endLine": 59, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 7, + "endLine": 60, + "endColumn": 22, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 5, + "endLine": 61, + "endColumn": 26, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 61, + "column": 11, + "endLine": 61, + "endColumn": 26, + "problem": "SetTransferListDeprecated", + "suggest": "", + "rule": "The taskpool setTransferList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setTransferList)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 5, + "endLine": 62, + "endColumn": 23, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 11, + "endLine": 62, + "endColumn": 23, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.json b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.json index 1c17b59df7a1612ee61e9a9368eed3b136b9bcfc..619623e56042c24574b9b22c8c7871014101b08e 100644 --- a/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.json +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages.ets.json @@ -15,14 +15,114 @@ ], "result": [ { - "line": 20, + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 60, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 1, + "endLine": 17, + "endColumn": 44, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 37, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 1, + "endLine": 19, + "endColumn": 68, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)", + "severity": "ERROR" + }, + { + "line": 24, "column": 5, - "endLine": 20, + "endLine": 24, + "endColumn": 50, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 5, + "endLine": 33, "endColumn": 52, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 37, + "column": 5, + "endLine": 37, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 5, + "endLine": 41, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 5, + "endLine": 45, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 5, + "endLine": 50, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 55, + "column": 5, + "endLine": 55, + "endColumn": 43, + "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/taskpool_deprecated_usages2.ets b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets new file mode 100755 index 0000000000000000000000000000000000000000..f79e1e32cc64a6ffae5b07d437702edd7c6aece3 --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets @@ -0,0 +1,33 @@ +/* + * 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 taskpool from '@ohos.taskpool'; +import { otherTaskPool as taskpool1 } from './@ohos.taskpool'; +import { taskpool as taskpool2 } from './@ohos.taskpool'; +function test1(){} +const array1: number[] =[1] +const transfer: ArrayBuffer[] =[] +let task = new taskpool1.Task(test1); +task.setCloneList(array1) +task.setTransferList(transfer) +new taskpool1.Task(test1).setTransferList(transfer); +function test(){ + const task3 = new taskpool2.Task(test1); + typeof task3.setTransferList(transfer); + return new taskpool2.Task(test1).setTransferList(); +} +let task4 = new taskpool.Task(test1); +task4.setCloneList([]) //error +task4.setCloneList(transfer) //error \ No newline at end of file diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.args.json b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..3ef4496a819a201892114d1c90f78ae32053c334 --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages2.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/taskpool_deprecated_usages2.ets.arkts2.json b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..e4183cf1b5bb5b962d919e12ef452964584a4053 --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 39, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 26, + "endLine": 20, + "endColumn": 27, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 10, + "endLine": 28, + "endColumn": 41, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 17, + "endLine": 31, + "endColumn": 30, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 7, + "endLine": 32, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 7, + "endLine": 33, + "endColumn": 19, + "problem": "SetCloneListDeprecated", + "suggest": "", + "rule": "The taskpool setCloneList interface is deleted from ArkTS1.2 (arkts-limited-stdlib-no-setCloneList)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.json b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..14da023dd0b347f06e79a6a58ed2a965ad18f232 --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages2.ets.json @@ -0,0 +1,28 @@ +{ + "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": 31, + "column": 5, + "endLine": 31, + "endColumn": 37, + "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/taskpool_deprecated_usages3.ets b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets new file mode 100755 index 0000000000000000000000000000000000000000..99eafb82960a351e05fd6a90c0cd45a937879983 --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets @@ -0,0 +1,22 @@ +/* + * 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 taskpool from '@ohos.taskpool'; +function test1(){} +export const task = new taskpool.Task(test1); +export class Task { + constructor(func: Function, ...args: Object[]){} + setTransferList(transfer?: ArrayBuffer[]): void{} + setCloneList(cloneList: Object[] | ArrayBuffer[]): void{} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.args.json b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.args.json new file mode 100755 index 0000000000000000000000000000000000000000..3ef4496a819a201892114d1c90f78ae32053c334 --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages3.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/taskpool_deprecated_usages3.ets.arkts2.json b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.arkts2.json new file mode 100755 index 0000000000000000000000000000000000000000..449be5d7945a1a914efc5ff077f0dbbc744de8ff --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.arkts2.json @@ -0,0 +1,48 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 15, + "column": 1, + "endLine": 15, + "endColumn": 39, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 15, + "endLine": 17, + "endColumn": 46, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 17, + "column": 26, + "endLine": 17, + "endColumn": 39, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.json b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.json new file mode 100755 index 0000000000000000000000000000000000000000..4fdd338ef26a4ff2a3ff6c93f48a14fd8c8c295d --- /dev/null +++ b/ets2panda/linter/test/main/taskpool_deprecated_usages3.ets.json @@ -0,0 +1,28 @@ +{ + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 17, + "column": 15, + "endLine": 17, + "endColumn": 46, + "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/ts-like-catch-type.ets b/ets2panda/linter/test/main/ts-like-catch-type.ets index 76d4be8122a044cab26465f3b6e83eb567e024a6..02c6d721fb9db4dc93c627434c7d75870dd29916 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets @@ -13,18 +13,14 @@ * limitations under the License. */ -function test() { - try { - let a: number = 1; - } catch (e) { - console.log('catch') - } +try { + throw new Error(); +} catch(e) { + e.message; + e.prop; } -function test2() { - try { - let a: number = 1; - } catch (e: any) { - console.log('catch') - } +try { + throw new Error(); +} catch(e) { } \ 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 2956a7461c93662772b93bad5274bb8915f22610..41e86435eea676858d5c259c012831fba6db5278 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,64 +15,14 @@ ], "result": [ { - "line": 18, - "column": 21, - "endLine": 18, - "endColumn": 22, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 5, - "endLine": 21, - "endColumn": 4, + "line": 20, + "column": 3, + "endLine": 20, + "endColumn": 9, "problem": "TsLikeCatchType", "suggest": "", "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", "severity": "ERROR" - }, - { - "line": 26, - "column": 21, - "endLine": 26, - "endColumn": 22, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 12, - "endLine": 27, - "endColumn": 18, - "problem": "CatchWithUnsupportedType", - "suggest": "", - "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 5, - "endLine": 29, - "endColumn": 4, - "problem": "TsLikeCatchType", - "suggest": "", - "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 15, - "endLine": 27, - "endColumn": 18, - "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/ts-like-catch-type.ets.json b/ets2panda/linter/test/main/ts-like-catch-type.ets.json index bd65f7efbe5b1a14b6001506f9a8511cd080d1d1..315ec6f0aeb96fceaa1d5d95ab22858aea3255e4 100644 --- a/ets2panda/linter/test/main/ts-like-catch-type.ets.json +++ b/ets2panda/linter/test/main/ts-like-catch-type.ets.json @@ -13,26 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 27, - "column": 12, - "endLine": 27, - "endColumn": 18, - "problem": "CatchWithUnsupportedType", - "suggest": "", - "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 15, - "endLine": 27, - "endColumn": 18, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/ts_overload.ets.arkts2.json b/ets2panda/linter/test/main/ts_overload.ets.arkts2.json index 013ef916fea24fed789c3c5816661b4ad1f9be64..625ed5b8331918d9b2851ec2693750f323c1c975 100644 --- a/ets2panda/linter/test/main/ts_overload.ets.arkts2.json +++ b/ets2panda/linter/test/main/ts_overload.ets.arkts2.json @@ -13,7 +13,7 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ + "result": [ { "line": 16, "column": 1, @@ -44,6 +44,26 @@ "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", "severity": "ERROR" }, + { + "line": 20, + "column": 16, + "endLine": 20, + "endColumn": 20, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 16, + "endLine": 22, + "endColumn": 20, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + }, { "line": 25, "column": 21, @@ -281,7 +301,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/rules/rule144.ets.json b/ets2panda/linter/test/rules/rule144.ets.json index c52a53a30f9636fb50e46086b03ff2f864d0fe20..9bbf5b7e7c41749d4583c23cfd4c6b7f4371e22e 100644 --- a/ets2panda/linter/test/rules/rule144.ets.json +++ b/ets2panda/linter/test/rules/rule144.ets.json @@ -274,6 +274,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 85, + "column": 1, + "endLine": 85, + "endColumn": 51, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 86, "column": 1, @@ -284,6 +294,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 86, + "column": 1, + "endLine": 86, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 86, "column": 32, @@ -304,6 +324,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 87, + "column": 1, + "endLine": 87, + "endColumn": 36, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 87, "column": 32, @@ -324,6 +354,26 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 88, + "column": 1, + "endLine": 88, + "endColumn": 34, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 1, + "endLine": 89, + "endColumn": 32, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 90, "column": 1, @@ -334,6 +384,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 90, + "column": 1, + "endLine": 90, + "endColumn": 53, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 91, "column": 1, @@ -344,6 +404,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 91, + "column": 1, + "endLine": 91, + "endColumn": 27, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 92, "column": 1, @@ -354,6 +424,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 92, + "column": 1, + "endLine": 92, + "endColumn": 25, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 93, "column": 1, @@ -364,6 +444,16 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 93, + "column": 1, + "endLine": 93, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 94, "column": 1, @@ -374,6 +464,86 @@ "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", "severity": "ERROR" }, + { + "line": 94, + "column": 1, + "endLine": 94, + "endColumn": 30, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 95, + "column": 1, + "endLine": 95, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 96, + "column": 1, + "endLine": 96, + "endColumn": 46, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 1, + "endLine": 97, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 98, + "column": 1, + "endLine": 98, + "endColumn": 39, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 99, + "column": 1, + "endLine": 99, + "endColumn": 38, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 1, + "endLine": 100, + "endColumn": 31, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, + { + "line": 101, + "column": 1, + "endLine": 101, + "endColumn": 29, + "problem": "InteropCallReflect", + "suggest": "", + "rule": "Reflect API usage is not allowed in interop calls when an \"Object\" parameter receives a class instance (arkts-interop-d2s-static-reflect-on-dynamic-instance)", + "severity": "ERROR" + }, { "line": 104, "column": 32, diff --git a/ets2panda/linter/test/rules/rule37.ets.migrate.json b/ets2panda/linter/test/rules/rule37.ets.migrate.json index ca88f857e960b437dcf767c0ac40be998c8f1236..0a1c7ec09788dc01f74297d811e3c342a1e47d88 100644 --- a/ets2panda/linter/test/rules/rule37.ets.migrate.json +++ b/ets2panda/linter/test/rules/rule37.ets.migrate.json @@ -13,5 +13,16 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 59, + "column": 21, + "endLine": 59, + "endColumn": 27, + "problem": "ConstructorIfaceFromSdk", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces.(sdk-ctor-signatures-iface)", + "severity": "ERROR" + } + ] } \ No newline at end of file diff --git a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json index 327b8e844f97bd5fb7074d01b52905840f6b3416..64896441f073959258440bf2a73e3f2e1a65ec78 100644 --- a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json @@ -211,7 +211,7 @@ "endColumn": 7, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Entry\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -221,7 +221,7 @@ "endColumn": 11, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Component\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -231,7 +231,7 @@ "endColumn": 62, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Color\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -241,7 +241,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"State\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -251,7 +251,7 @@ "endColumn": 9, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"List\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -261,7 +261,7 @@ "endColumn": 14, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ForEach\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -271,7 +271,7 @@ "endColumn": 17, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"ListItem\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -281,7 +281,7 @@ "endColumn": 15, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"Text\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json index d6b0d31865a62a09f14a7eec9668c73ea66a3172..5b7d055ce4855c051b014955fdd6df71123e3162 100644 --- a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json @@ -44,6 +44,16 @@ "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", "severity": "ERROR" }, + { + "line": 22, + "column": 26, + "endLine": 22, + "endColumn": 46, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 22, "column": 26, @@ -54,6 +64,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 41, + "column": 28, + "endLine": 41, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 41, "column": 28, @@ -64,6 +84,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 45, + "column": 29, + "endLine": 45, + "endColumn": 49, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 45, "column": 29, diff --git a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json index 5b41bb7baa2ffce5dba97d60b7e91be608ad92c4..646d8423c0f782dd969a4170717343aacbd163fb 100644 --- a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json @@ -24,16 +24,6 @@ "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", "severity": "ERROR" }, - { - "line": 18, - "column": 3, - "endLine": 20, - "endColumn": 4, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 18, "column": 48, @@ -94,6 +84,16 @@ "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", "severity": "ERROR" }, + { + "line": 28, + "column": 28, + "endLine": 28, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 28, "column": 28, @@ -104,6 +104,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 32, + "column": 26, + "endLine": 32, + "endColumn": 46, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 32, "column": 26, @@ -201,7 +211,7 @@ "endColumn": 59, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" }, { @@ -211,7 +221,7 @@ "endColumn": 61, "problem": "UIInterfaceImport", "suggest": "", - "rule": "ArkUI interface should be imported before using (arkui-modular-interface)", + "rule": "The ArkUI interface \"DataChangeListener\" should be imported before it is used (arkui-modular-interface)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets index e05617b2ffb84ecbd04c71f0dc7b94f63b0f1138..d7922e5530f0b559ca570e8f25ea707edf6464cf 100644 --- a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets +++ b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { rcp } from '@kit.RemoteCommunicationKit'; +import mainRcp,{ rcp } from '@kit.RemoteCommunicationKit'; class LI implements rcp.WriteFile{ write(buffer: ArrayBuffer): Promise { // Error throw new Error('Method not implemented.'); @@ -41,4 +41,16 @@ export class LocalDataSource implements IDataSourcePrefetching { cancel(index: number): void | Promise { throw new Error("LocalDataSource Method not implemented."); } +} + +class L3 implements mainRcp.WriteFile { + write(buffer: ArrayBuffer): Promise { // error + throw new Error('Method not implemented.'); + } +} + +class L4 implements rcp.WriteFile { + write(buffer: ArrayBuffer): Promise { // error + throw new Error('Method not implemented.'); + } } \ No newline at end of file diff --git a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json index 5d0e2d9cb631c646033d268395725ece2391e0d6..ab0cf4ecd5c92fd1dd761b877acf0948618a2e13 100644 --- a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json @@ -24,16 +24,6 @@ "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", "severity": "ERROR" }, - { - "line": 18, - "column": 3, - "endLine": 20, - "endColumn": 4, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 18, "column": 48, @@ -94,6 +84,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 37, + "column": 28, + "endLine": 37, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 37, "column": 28, @@ -104,6 +104,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 41, + "column": 26, + "endLine": 41, + "endColumn": 46, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 41, "column": 26, @@ -113,6 +123,46 @@ "suggest": "", "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" + }, + { + "line": 47, + "column": 3, + "endLine": 49, + "endColumn": 4, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 48, + "endLine": 47, + "endColumn": 52, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 3, + "endLine": 55, + "endColumn": 4, + "problem": "LimitedVoidTypeFromSdk", + "suggest": "", + "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 53, + "column": 48, + "endLine": 53, + "endColumn": 52, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/sdkwhite/quoted_hyphen_props_deprecated_sdk2.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/quoted_hyphen_props_deprecated_sdk2.ets.arkts2.json index f2d125c5784100f6d7f32f00cfe38427f50a997b..84106d351ab25809f282d4840cec7be3e42bdfe5 100755 --- a/ets2panda/linter/test/sdkwhite/quoted_hyphen_props_deprecated_sdk2.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/quoted_hyphen_props_deprecated_sdk2.ets.arkts2.json @@ -14,6 +14,26 @@ "limitations under the License." ], "result": [ + { + "line": 42, + "column": 10, + "endLine": 42, + "endColumn": 20, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 20, + "endLine": 48, + "endColumn": 30, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, { "line": 65, "column": 5, diff --git a/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets b/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets index c50d5885dafbfff29cadcffe094db980bf764b07..d14c65ae1c861531b81503aa00cd20018f660386 100755 --- a/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets +++ b/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets @@ -13,8 +13,30 @@ * limitations under the License. */ -import {cloudDatabase} from '@hms.core.deviceCloudGateway.cloudDatabase'; +import cloudDatabase from '@hms.core.deviceCloudGateway.cloudDatabase'; class Test extends cloudDatabase.DatabaseObject{ - + query = new cloudDatabase.DatabaseQuery(Test); //Error + equalTo(){ + return this.query.equalTo('test',''); + } } -new cloudDatabase.DatabaseQuery(Test); // NOT OK \ No newline at end of file +const localQuery = new cloudDatabase.DatabaseQuery(Test); //Error +class LocalDatabaseQuery extends cloudDatabase.DatabaseQuery{ //Error + query = new cloudDatabase.DatabaseQuery(Test); //Error + set(query:cloudDatabase.DatabaseQuery){ //Error + query.equalTo('test',''); + } + getTypeQuery(): cloudDatabase.DatabaseQuery { //Error + typeof new cloudDatabase.DatabaseQuery(Test); //Error + return new cloudDatabase.DatabaseQuery(Test); //Error + } + getEqual(){ + this.query = new Test().equalTo(); //Error? + } + +} +function useDatabaseQuery1(query:cloudDatabase.DatabaseQuery){ //Error + console.log(' '+new cloudDatabase.DatabaseQuery(Test)); //Error +} +class DatabaseQuery{} +new DatabaseQuery(); \ No newline at end of file diff --git a/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.arkts2.json index 745ab994b23232173122f6924c1d6ca84dd291a9..0356091ac5abbd0faa46843c6a1c1ccd785e8d1a 100755 --- a/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.arkts2.json @@ -15,20 +15,200 @@ ], "result": [ { - "line": 20, - "column": 5, - "endLine": 20, - "endColumn": 32, + "line": 18, + "column": 3, + "endLine": 18, + "endColumn": 49, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 15, + "endLine": 18, + "endColumn": 42, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 29, + "endLine": 18, + "endColumn": 42, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 3, + "endLine": 19, + "endColumn": 10, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 8, + "endLine": 23, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 25, + "endLine": 23, + "endColumn": 52, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 39, + "endLine": 23, + "endColumn": 52, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 48, + "endLine": 24, + "endColumn": 61, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 3, + "endLine": 25, + "endColumn": 49, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 15, + "endLine": 25, + "endColumn": 42, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 29, + "endLine": 25, + "endColumn": 42, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 27, + "endLine": 26, + "endColumn": 40, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 33, + "endLine": 29, + "endColumn": 46, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 16, + "endLine": 30, + "endColumn": 43, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 30, + "column": 30, + "endLine": 30, + "endColumn": 43, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 16, + "endLine": 31, + "endColumn": 43, + "problem": "DynamicCtorCall", + "suggest": "", + "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 30, + "endLine": 31, + "endColumn": 43, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 48, + "endLine": 38, + "endColumn": 61, + "problem": "ConstructorTypesDeprecated", + "suggest": "", + "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 23, + "endLine": 39, + "endColumn": 50, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 20, - "column": 19, - "endLine": 20, - "endColumn": 32, + "line": 39, + "column": 37, + "endLine": 39, + "endColumn": 50, "problem": "ConstructorTypesDeprecated", "suggest": "", "rule": "Constructor types are not supported - use lambda functions instead. (sdk-constructor-funcs)", diff --git a/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.json b/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.json index 9f305c86d7ff705098b1e480818e125d5e6e3a4a..7cf57b141b3d43579fa1e172817e76e9f78133aa 100755 --- a/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.json +++ b/ets2panda/linter/test/sdkwhite/sdk_constructor_funcs.ets.json @@ -13,5 +13,46 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [] + "result": [ + { + "line": 18, + "column": 3, + "endLine": 18, + "endColumn": 49, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 3, + "endLine": 19, + "endColumn": 10, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 8, + "endLine": 23, + "endColumn": 58, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 3, + "endLine": 25, + "endColumn": 49, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] } diff --git a/ets2panda/linter/test/sdkwhite/sdk_type_query.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/sdk_type_query.ets.arkts2.json index 67a42975bf378b67bc2de3e51dd05fa085910e55..7053b9055fcfce3cb3c06c48e3e8005c16d70500 100755 --- a/ets2panda/linter/test/sdkwhite/sdk_type_query.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/sdk_type_query.ets.arkts2.json @@ -174,6 +174,16 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "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": 48, "column": 14, diff --git a/ets2panda/package-lock.json b/ets2panda/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..8348c83704ddf9d1b803d3199cbc9630f365bff8 --- /dev/null +++ b/ets2panda/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "ets2panda", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}