diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index ca016e788deed8cac98949f5a15cda3d9feb096a..f3933f6186a7b0f6bc555b925e37937f090d7433 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -1473,19 +1473,18 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - if ( - ts.isBinaryExpression(propertyAccessNode.parent) && - propertyAccessNode.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken - ) { - if (!ts.isExpressionStatement(propertyAccessNode.parent.parent)) { - return; - } - const autofix = this.autofixer?.fixInteropBinaryExpression(propertyAccessNode.parent); - this.incrementCounters(propertyAccessNode.parent, FaultID.InteropObjectProperty, autofix); - } else if ( - ts.isExpressionStatement(propertyAccessNode.parent) || - ts.isVariableDeclaration(propertyAccessNode.parent) - ) { + 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); } 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 index 88784c2392e997667f1905cc123a601a9c260d2f..6734ea601860e570b16353085ab2dddd748c54d2 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.arkts2.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.arkts2.json @@ -373,6 +373,26 @@ "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 index 02657b315262d64811922b09efbc6f62fb2f933a..8bf1b635a68ff6b9b200e96005430d8081c31da9 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json @@ -787,6 +787,48 @@ "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/increases_decreases_js_obj.ets.arkts2.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.arkts2.json index 5733e4a0f97db5f9cd00d71fb1957baef5ac7e53..20513d8aadfe64b7b17b4d954a458946d60ab978 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.arkts2.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.arkts2.json @@ -44,6 +44,16 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 12, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 18, "column": 5, @@ -54,6 +64,16 @@ "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" + }, { "line": 19, "column": 5, @@ -64,6 +84,16 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 12, + "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, @@ -74,6 +104,16 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "line": 20, + "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, @@ -84,6 +124,16 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "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": 23, "column": 1, @@ -94,6 +144,16 @@ "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": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 24, "column": 1, @@ -104,6 +164,16 @@ "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", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 25, "column": 1, @@ -113,6 +183,16 @@ "suggest": "", "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" } ] } diff --git a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json index 74a00a0cf400aac6057b177eb9ef4f11c895846d..e48a8565b9797a819a48576450a0c1ddaf2d4b5d 100644 --- a/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/increases_decreases_js_obj.ets.autofix.json @@ -14,7 +14,7 @@ "limitations under the License." ], "result": [ - { + { "line": 15, "column": 1, "endLine": 15, @@ -86,6 +86,27 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 12, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 677, + "end": 684, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 17, + "column": 5, + "endLine": 17, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 18, "column": 5, @@ -107,6 +128,27 @@ "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", + "autofix": [ + { + "start": 693, + "end": 700, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 18, + "column": 7, + "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": 5, @@ -128,6 +170,27 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 12, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 705, + "end": 712, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 19, + "column": 5, + "endLine": 19, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 20, "column": 5, @@ -149,6 +212,27 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "line": 20, + "column": 7, + "endLine": 20, + "endColumn": 14, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 721, + "end": 728, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 20, + "column": 7, + "endLine": 20, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 22, "column": 1, @@ -170,6 +254,27 @@ "rule": "Interop objects can't be incremented or decremented (arkts-interop-js2s-self-addtion-reduction)", "severity": "ERROR" }, + { + "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, @@ -191,6 +296,27 @@ "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", + "autofix": [ + { + "start": 742, + "end": 749, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 24, "column": 1, @@ -212,6 +338,27 @@ "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, @@ -232,6 +379,27 @@ "suggest": "", "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" } ] } diff --git a/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json b/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json index f4460de05a9e7dc5972246339c58ae190b3e0d0c..d6f91a557d1e1a3e03b5b1a4c6049645c84a0a5b 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.arkts2.json @@ -44,6 +44,16 @@ "rule": "Casting interop JS objects to primitive types is not allowed (arkts-interop-js2s-convert-js-type)", "severity": "ERROR" }, + { + "line": 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, @@ -54,6 +64,16 @@ "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, @@ -64,6 +84,16 @@ "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, @@ -74,6 +104,16 @@ "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, 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 cfa646085ae972fb91eb01d4262ff3e50896825c..b49b275bb55fe496eed776379f50e210e3354a4b 100644 --- a/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_convert_import.ets.autofix.json @@ -75,6 +75,27 @@ "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", + "autofix": [ + { + "start": 774, + "end": 781, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 20, + "column": 18, + "endLine": 20, + "endColumn": 25 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 21, "column": 20, @@ -96,6 +117,27 @@ "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", + "autofix": [ + { + "start": 812, + "end": 821, + "replacementText": "foo2.getPropertyByName(\"bool\")", + "line": 21, + "column": 20, + "endLine": 21, + "endColumn": 29 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 22, "column": 19, @@ -117,6 +159,27 @@ "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", + "autofix": [ + { + "start": 853, + "end": 861, + "replacementText": "foo3.getPropertyByName(\"str\")", + "line": 22, + "column": 19, + "endLine": 22, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 23, "column": 19, @@ -138,6 +201,27 @@ "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", + "autofix": [ + { + "start": 892, + "end": 900, + "replacementText": "foo4.getPropertyByName(\"big\")", + "line": 23, + "column": 19, + "endLine": 23, + "endColumn": 27 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 26, "column": 9, 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 0d056023ed8e8713385e538bf7503c5f56f868ac..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 @@ -273,6 +273,26 @@ "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", + "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/interop_import_js_compare.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json index 8b8b4fe079c2d73f6205158b607ca2de110deb0d..2b90e5d9f02599b8a3707341f813b61aef70870f 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json @@ -577,6 +577,48 @@ "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_index.ets.arkts2.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.arkts2.json index 7586fcda516c5f43d38db25d1c078340dd210010..5414e5c1c43e4c950cfe4cd929b5d62d40548533 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 @@ -104,6 +104,16 @@ "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, @@ -124,6 +134,16 @@ "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, 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 8e7830812f31d816979d970d4b868fe9d09e4b29..3652409b23fbf7d2b35f03aa6b806a6f48d6f1da 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 @@ -199,6 +199,27 @@ "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, @@ -241,6 +262,27 @@ "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, 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 adc49e209c6e53d525ad87a85dc33c2be55914fd..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 @@ -23,8 +23,8 @@ arr.getPropertyByIndex(1.0) arr.setPropertyByIndex(3.0, ESValue.wrap(4.0)) let arr1 = ff3.getPropertyByName("arr") -let len: number = arr1.length as number -for (let i: number = 0.0; i < arr1.length; ++i) { +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 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 2fdc4e604ec7c6f910fa33f4722bf2ac4ae60ca8..d9f270ec5e6f677618a97014922a8567d43b1ca2 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 @@ -194,6 +194,16 @@ "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, + { + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 15, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 32, "column": 5, @@ -214,6 +224,16 @@ "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", "severity": "ERROR" }, + { + "line": 34, + "column": 5, + "endLine": 34, + "endColumn": 11, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 34, "column": 5, @@ -294,6 +314,16 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, + { + "line": 51, + "column": 11, + "endLine": 51, + "endColumn": 21, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 54, "column": 3, @@ -554,6 +584,16 @@ "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", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 84, "column": 29, 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 415bd82dc4208d62065c844da75ccded6a6495fd..a85d137032e0362398eb7bbc7cce90fccd764b3c 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 @@ -374,6 +374,27 @@ "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", "severity": "ERROR" }, + { + "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" + }, { "line": 32, "column": 5, @@ -416,6 +437,27 @@ "rule": "Importing data directly from the \"JS\" module for comparison is not supported (arkts-interop-js2s-compare-js-data)", "severity": "ERROR" }, + { + "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" + }, { "line": 34, "column": 5, @@ -540,6 +582,27 @@ "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", "severity": "ERROR" }, + { + "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" + }, { "line": 54, "column": 3, @@ -1009,6 +1072,27 @@ "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, 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 index a388ad4be8c63120888e9e286e64ea86074e1ba8..e1fc6d18dd6d307f7f56be2cebc081176947a3fb 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.arkts2.json @@ -134,6 +134,16 @@ "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, @@ -294,6 +304,16 @@ "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, @@ -334,6 +354,16 @@ "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, diff --git a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json index bf0571a063533513cd92b5d75d7460f612526031..a080a8877dd435a10899ad762d2ee6ab0862b41b 100644 --- a/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_typeof_js.ets.autofix.json @@ -271,6 +271,27 @@ "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, @@ -574,6 +595,27 @@ "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, @@ -658,6 +700,27 @@ "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, diff --git a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets index e76e5da604bfb9a165443bea31759aaae62188da..3aa24611b1453b4efbe69a0875f4b5e7194d0deb 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets @@ -14,13 +14,50 @@ */ 'use static' -import {foo, person} from "./interop_not_have_property_js" +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 +if (foo.name = "456") { print("true") } let a = new foo() -a.age = 12 \ No newline at end of file +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 index 4b9d5b3863831a92b9d05b5f61cdb688e4c20351..18802c22d55cdd07435bcafaf0f27f6cfc11847f 100644 --- 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)", @@ -125,9 +125,29 @@ "severity": "ERROR" }, { - "line": 25, + "line": 24, "column": 5, - "endLine": 25, + "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": "", @@ -135,9 +155,9 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 9, - "endLine": 25, + "endLine": 26, "endColumn": 18, "problem": "InstantiatedJsOjbect", "suggest": "", @@ -145,9 +165,9 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 1, - "endLine": 26, + "endLine": 27, "endColumn": 11, "problem": "InteropObjectProperty", "suggest": "", @@ -155,14 +175,334 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 9, - "endLine": 26, + "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 index 1324eb3b623f8641e9e9d24c62eb5f70891a2253..d66995a3c66e2ece5eb31247a9916ca8ce6bf5c4 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_arkts2.ets.autofix.json @@ -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, @@ -83,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, @@ -104,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, @@ -125,8 +125,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 717, - "end": 719, + "start": 764, + "end": 766, "replacementText": "23.0", "line": 21, "column": 14, @@ -146,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, @@ -167,8 +167,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 735, - "end": 736, + "start": 782, + "end": 783, "replacementText": "2.0", "line": 22, "column": 16, @@ -188,8 +188,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 738, - "end": 739, + "start": 785, + "end": 786, "replacementText": "3.0", "line": 22, "column": 19, @@ -209,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, @@ -230,8 +230,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 751, - "end": 753, + "start": 798, + "end": 800, "replacementText": "12.0", "line": 23, "column": 11, @@ -244,9 +244,51 @@ "severity": "ERROR" }, { - "line": 25, + "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": 25, + "endLine": 26, "endColumn": 18, "problem": "AnyType", "suggest": "", @@ -254,19 +296,19 @@ "severity": "ERROR" }, { - "line": 25, + "line": 26, "column": 9, - "endLine": 25, + "endLine": 26, "endColumn": 18, "problem": "InstantiatedJsOjbect", "autofix": [ { - "start": 763, - "end": 772, + "start": 850, + "end": 859, "replacementText": "foo.instantiate()", - "line": 25, + "line": 26, "column": 9, - "endLine": 25, + "endLine": 26, "endColumn": 18 } ], @@ -275,19 +317,19 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 1, - "endLine": 26, + "endLine": 27, "endColumn": 11, "problem": "InteropObjectProperty", "autofix": [ { - "start": 773, - "end": 783, + "start": 860, + "end": 870, "replacementText": "a.setPropertyByName(\"age\", ESValue.wrap(12))", - "line": 26, + "line": 27, "column": 1, - "endLine": 26, + "endLine": 27, "endColumn": 11 } ], @@ -296,25 +338,697 @@ "severity": "ERROR" }, { - "line": 26, + "line": 27, "column": 9, - "endLine": 26, + "endLine": 27, "endColumn": 11, "problem": "NumericSemantics", "autofix": [ { - "start": 781, - "end": 783, + "start": 868, + "end": 870, "replacementText": "12.0", - "line": 26, + "line": 27, "column": 9, - "endLine": 26, + "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 aa378b7cdb4ef25f5efdc51efc742feadd27c0b0..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,16 +18,16 @@ "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": 25, + "line": 26, "column": 5, - "endLine": 25, + "endLine": 26, "endColumn": 18, "problem": "AnyType", "suggest": "", 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 41e6e710a6a039c31c94fc6284b0b535ccc208a0..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 @@ -17,6 +17,11 @@ 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") @@ -24,6 +29,43 @@ 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)) +if (foo.setPropertyByName("name", ESValue.wrap("456"))) { print("true") } let a = foo.instantiate() -a.setPropertyByName("age", ESValue.wrap(12.0)) \ No newline at end of file +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 5d0bee805955ab80029eb797ece8afc7f6907d4e..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 @@ -45,14 +45,214 @@ "severity": "ERROR" }, { - "line": 28, + "line": 20, "column": 5, - "endLine": 28, + "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.arkts2.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.arkts2.json index 622761b380a175be670c7374af4cafe45e881106..ccb4943134ffca9cc6af97e2bdd741057074e0e4 100644 --- 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 @@ -34,6 +34,16 @@ "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, @@ -44,6 +54,16 @@ "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, @@ -54,6 +74,16 @@ "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" + }, { "line": 21, "column": 1, @@ -64,6 +94,16 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 21, + "column": 2, + "endLine": 21, + "endColumn": 9, + "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, @@ -74,6 +114,16 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 22, + "column": 3, + "endLine": 22, + "endColumn": 10, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 23, "column": 1, @@ -84,6 +134,16 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 10, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 24, "column": 1, @@ -94,6 +154,16 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 24, + "column": 3, + "endLine": 24, + "endColumn": 10, + "problem": "InteropObjectProperty", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 25, "column": 1, @@ -103,6 +173,16 @@ "suggest": "", "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "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/interop_not_have_property_num_arkts2.ets.autofix.json b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json index fc4732acc47bc4af5e2f97cf2cfaad248fe51d35..c638dec23eb3a73a32118f3b47305f1a70ee4777 100644 --- a/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_not_have_property_num_arkts2.ets.autofix.json @@ -65,6 +65,27 @@ "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": 653, + "end": 660, + "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, @@ -86,6 +107,27 @@ "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": 663, + "end": 670, + "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, @@ -107,6 +149,27 @@ "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": 673, + "end": 680, + "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" + }, { "line": 21, "column": 1, @@ -128,6 +191,27 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 21, + "column": 2, + "endLine": 21, + "endColumn": 9, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 683, + "end": 690, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 21, + "column": 2, + "endLine": 21, + "endColumn": 9 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 22, "column": 1, @@ -149,6 +233,27 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 22, + "column": 3, + "endLine": 22, + "endColumn": 10, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 694, + "end": 701, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 22, + "column": 3, + "endLine": 22, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 23, "column": 1, @@ -170,6 +275,27 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 10, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 706, + "end": 713, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 23, + "column": 3, + "endLine": 23, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 24, "column": 1, @@ -191,6 +317,27 @@ "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" }, + { + "line": 24, + "column": 3, + "endLine": 24, + "endColumn": 10, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 718, + "end": 725, + "replacementText": "foo.getPropertyByName(\"num\")", + "line": 24, + "column": 3, + "endLine": 24, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 25, "column": 1, @@ -211,6 +358,27 @@ "suggest": "", "rule": "Interop object does not have property num (arkts-interop-js2s-unary-op)", "severity": "ERROR" + }, + { + "line": 25, + "column": 3, + "endLine": 25, + "endColumn": 10, + "problem": "InteropObjectProperty", + "autofix": [ + { + "start": 730, + "end": 737, + "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/no_js_instanceof.ets.arkts2.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.arkts2.json index 616006bedfa5985d09e37f9e6ad479315039b548..4c2e0aa32a85010fb6a1740e8c9d192c60057df8 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.arkts2.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.arkts2.json @@ -154,6 +154,16 @@ "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", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 74, "column": 5, @@ -164,6 +174,16 @@ "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", + "suggest": "", + "rule": "Properties of interop objects can't be accessed directly (arkts-interop-js2s-access-js-prop)", + "severity": "ERROR" + }, { "line": 74, "column": 22, diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json index c1c3153c902ced5a24f5c3e25aa1c7c191e5ef51..8b4189586e0b1125edaff37961ec27611be6773f 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.autofix.json @@ -306,6 +306,27 @@ "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, @@ -327,6 +348,27 @@ "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, diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets index 729ddeb90e7e63268dd5dabbbe8942f6f65f7249..b71a99dcc06a6df1d775598ef974668c47b22515 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.ets @@ -76,7 +76,7 @@ if(b().isInstanceOf(Array)) { } -const myDog: MyNamespace.Dog = new MyNamespace.Dog('Buddy'); +const myDog: MyNamespace.Dog = new MyNamespace.getPropertyByName("Dog")('Buddy'); if (myDog.isInstanceOf(MyNamespace.Dog)) { console.log("This is a Dog!"); diff --git a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json index 992f388c81b589589fd96d52e0ea0603ba4c6188..63aabda70294bfb97625479c42d6e0484f4acc62 100644 --- a/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json +++ b/ets2panda/linter/test/interop/no_js_instanceof.ets.migrate.json @@ -108,7 +108,7 @@ "line": 79, "column": 36, "endLine": 79, - "endColumn": 51, + "endColumn": 65, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", 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 index c935900b7d1d21c644eeee800720f6856bb53686..13a3e19d15ee7fea3b3f88f509ec22e8b06a9f6c 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.arkts2.json +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.arkts2.json @@ -20,6 +20,16 @@ "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, @@ -30,6 +40,16 @@ "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, @@ -40,6 +60,16 @@ "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, @@ -49,6 +79,16 @@ "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 index f9cba0c86385e77bfab4a5d927efed836a9f886f..07cb92eb1a8bc087eb8a4dbbc0cf08eda485a176 100644 --- a/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/unary_operation_js_obj.ets.autofix.json @@ -65,6 +65,27 @@ "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, @@ -86,6 +107,27 @@ "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, @@ -107,6 +149,27 @@ "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, @@ -127,6 +190,27 @@ "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