diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index ce3a05264e15bfc7722d0564b5428a8bcd3a7783..1cddde25fec676a16c05823bcea0cbf08047c108 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -103,7 +103,7 @@ import { customLayoutFunctionName } from './utils/consts/ArkuiConstants'; import { arkuiImportList } from './utils/consts/ArkuiImportList'; -import type { ForbidenAPICheckResult } from './utils/consts/InteropAPI'; +import type { IdentifierAndArguments, ForbidenAPICheckResult } from './utils/consts/InteropAPI'; import { NONE, OBJECT_LITERAL, @@ -1424,14 +1424,16 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } return current; - } + }; const firstObjNode = getFirstObjectNode(propertyAccessNode); const isFromJs = this.tsUtils.isJsImport(firstObjNode); - if(isFromJs) { - if (ts.isBinaryExpression(propertyAccessNode.parent) && - propertyAccessNode.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken) { + 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 { @@ -2037,7 +2039,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); } @@ -4556,9 +4558,7 @@ 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; } @@ -7890,7 +7890,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; } @@ -8872,23 +8877,77 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return targetTypes.includes(storageType.getText()); } - private handleAwaitExpression(node: ts.Node): void { + private getIdentifierForAwaitExpr(awaitExpr: ts.AwaitExpression): IdentifierAndArguments { + void this; + + let ident: undefined | ts.Identifier; + let args: ts.NodeArray | undefined; + + const expr = awaitExpr.expression; + if (ts.isCallExpression(expr)) { + 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 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; - } - return false; - }; - const expr = awaitExpr.expression; - checkAndReportJsImportAwait(expr); - if (ts.isCallExpression(expr)) { - checkAndReportJsImportAwait(expr.expression); + 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 { @@ -8983,7 +9042,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); } diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 564ebc117d6aab1fc815b6d3331695fdf5f3ac17..ca54c8b8f50ce5fbc375a35bcc2d11c845acd75b 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -53,6 +53,7 @@ import { WRAP, INSTANTIATE, TO_NUMBER, + TO_PROMISE, INVOKE, INVOKE_METHOD } from '../utils/consts/InteropAPI'; @@ -3603,7 +3604,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,7 +3623,8 @@ 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 }]; } @@ -3757,30 +3759,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( @@ -3986,8 +4010,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 { @@ -4250,6 +4277,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( diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index 2327bf026c6769c0aebd3371a8236a1a6f0319de..00466a8740ed3788fcdaa87216ea8c9a8fda234d 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -3654,7 +3654,7 @@ export class TsUtils { ) { return false; } - + return true; } current = current.parent; diff --git a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts index c3566b66db6a4acb482811cfb3857b8fdc716f61..d098376b6f3046598e47b16f6cdc0169e894bc0c 100644 --- a/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts +++ b/ets2panda/linter/src/lib/utils/consts/InteropAPI.ts @@ -12,6 +12,7 @@ * 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'; @@ -20,6 +21,7 @@ export const WRAP = 'wrap'; export const INSTANTIATE = 'instantiate'; export const INVOKE = 'invoke'; export const INVOKE_METHOD = 'invokeMethod'; +export const TO_PROMISE = 'toPromise'; export const REFLECT_PROPERTIES = [ 'get', @@ -73,3 +75,8 @@ export enum InteropType { LEGACY = '1.0', NONE = 'none' } + +export type IdentifierAndArguments = { + ident: undefined | ts.Identifier; + args: ts.NodeArray | undefined; +}; 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 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..f542b702eab1b70bb02b255656758c6db0cb007d --- 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,933 @@ { - "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": 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().invokeMethod(\"getName\").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().invokeMethod(\"setAge\", 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" + } + ] } 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..aef4644b33262e51a60c553fe1db8d4f86909a72 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 @@ -79,5 +79,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/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..65598b949835241dd330046a000631cfb21bd0df --- a/ets2panda/linter/test/interop/no_await_js_promise.ets.arkts2.json +++ b/ets2panda/linter/test/interop/no_await_js_promise.ets.arkts2.json @@ -54,16 +54,6 @@ "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", "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, "column": 10, @@ -74,26 +64,6 @@ "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", "severity": "ERROR" }, - { - "line": 32, - "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, @@ -164,16 +134,6 @@ "rule": "\"Await\" operator can't be used with interop objects (arkts-interop-js2s-await-js-promise)", "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, "column": 2, @@ -193,26 +153,6 @@ "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 +}