diff --git a/linter-4.2/cookbook_convertor/res/recipes.rst b/linter-4.2/cookbook_convertor/res/recipes.rst index ad0382359d2320388086e8f5eeda4c3951eef063..c069dd211eec6b750a4ee98a488bf23e88f7b19d 100644 --- a/linter-4.2/cookbook_convertor/res/recipes.rst +++ b/linter-4.2/cookbook_convertor/res/recipes.rst @@ -364,40 +364,6 @@ In |TS|, arrays can be declared as either ``Array`` or ``T[]``. Currently, let x: string[] = ["1", "2", "3"]; let y: string[] = ["1", "2", "3"]; // Array is not supported currently -.. _R013: - -|CB_R| #13: Use ``Object[]`` instead of tuples ----------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -Currently, |LANG| does not support tuples. You can use arrays of ``Object`` -(``Object[]``) to emulate tuples. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - var t: [number, string] = [3, "three"] - var n = t[0] - var s = t[1] - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - let t: Object[] = [3, "three"] - let n = t[0] - let s = t[1] - -|CB_SEE| -~~~~~~~~ - -* :ref:`R013` - .. _R014: |CB_R| #14: Use ``class`` instead of a type with call signature diff --git a/linter-4.2/docs/rules/recipe13.md b/linter-4.2/docs/rules/recipe13.md deleted file mode 100644 index d7a51272784452920c14541982f19a12011276bc..0000000000000000000000000000000000000000 --- a/linter-4.2/docs/rules/recipe13.md +++ /dev/null @@ -1,33 +0,0 @@ -# Use ``Object[]`` instead of tuples - -Rule ``arkts-no-tuples`` - -**Severity: error** - -Currently, ArkTS does not support tuples. Use arrays of ``Object`` -(``Object[]``) to emulate tuples. - - -## TypeScript - - -``` - - var t: [number, string] = [3, "three"] - var n = t[0] - var s = t[1] - -``` - -## ArkTS - - -``` - - let t: Object[] = [3, "three"] - let n = t[0] - let s = t[1] - -``` - - diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index 87c5dc8fff787ea98ea12ebb0887704ac3ea85af..158105ef4fa7adeb25568534cf9f4a6c6da4acba 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -32,7 +32,7 @@ cookBookTag[9] = ''; cookBookTag[10] = ''; cookBookTag[11] = ''; cookBookTag[12] = ''; -cookBookTag[13] = 'Use "Object[]" instead of tuples (arkts-no-tuples)'; +cookBookTag[13] = ''; cookBookTag[14] = 'Use "class" instead of a type with call signature (arkts-no-call-signatures)'; cookBookTag[15] = 'Use "class" instead of a type with constructor signature (arkts-no-ctor-signatures-type)'; cookBookTag[16] = 'Only one static block is supported (arkts-no-multiple-static-blocks)'; diff --git a/linter-4.2/src/Problems.ts b/linter-4.2/src/Problems.ts index 373f7768862f074bb310c381ed7f031759abd5d2..0d65d21b391bcac79ce8e32561a0964eced277af 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -14,8 +14,8 @@ */ export enum FaultID { - AnyType, SymbolType, TupleType, ObjectLiteralNoContextType, ArrayLiteralNoContextType, - ComputedPropertyName, LiteralAsPropertyName, TypeQuery, TupleLiteral, RegexLiteral, IsOperator, + AnyType, SymbolType, ObjectLiteralNoContextType, ArrayLiteralNoContextType, + ComputedPropertyName, LiteralAsPropertyName, TypeQuery, RegexLiteral, IsOperator, DestructuringParameter, YieldExpression, InterfaceMerging, EnumMerging, InterfaceExtendsClass, IndexMember, WithStatement, ThrowStatement, IndexedAccessType, UnknownType, ForInStatement, InOperator, KeyOfOperator, ImportFromPath, FunctionExpression, IntersectionType, @@ -54,8 +54,6 @@ faultsAttrs[FaultID.DeclWithDuplicateName] = {migratable: true, cookBookRef: '4' faultsAttrs[FaultID.VarDeclaration] = {migratable: true, cookBookRef: '5',}; faultsAttrs[FaultID.AnyType] = {cookBookRef: '8'}; faultsAttrs[FaultID.UnknownType] = {cookBookRef: '8',}; -faultsAttrs[FaultID.TupleType] = {cookBookRef: '13',}; -faultsAttrs[FaultID.TupleLiteral] = {cookBookRef: '13',}; faultsAttrs[FaultID.CallSignature] = {cookBookRef: '14',}; faultsAttrs[FaultID.ConstructorType] = {cookBookRef: '15',}; faultsAttrs[FaultID.MultipleStaticBlocks] = {cookBookRef: '16',}; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index c2a79bc87d4d7350fd3f530e5046ce2534d4d920..ccf1c8a89695ad5b260682a2e8b2d7904eaebc98 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -569,11 +569,6 @@ export class TypeScriptLinter { return; let arrayLitNode = node as ts.ArrayLiteralExpression; - - // check element types - if (ts.isUnionTypeNode(arrayLitNode)) - this.incrementCounters(node, FaultID.TupleLiteral); - let noContextTypeForArrayLiteral = false; // check that array literal consists of inferrable types diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index 1834923b6fb67f8c2ebf986468d177e1c121a9a4..0e5d02109a01b823ad76ec9e802e5e056079d50c 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -34,13 +34,11 @@ export class LinterConfig { // Set the feature descriptions (for the output). LinterConfig.nodeDesc[FaultID.AnyType] = '"any" type'; LinterConfig.nodeDesc[FaultID.SymbolType] = '"symbol" type'; - LinterConfig.nodeDesc[FaultID.TupleType] = 'Tuple type'; LinterConfig.nodeDesc[FaultID.ObjectLiteralNoContextType] = 'Object literals with no context Class or Interface type'; LinterConfig.nodeDesc[FaultID.ArrayLiteralNoContextType] = 'Array literals with no context Array type'; LinterConfig.nodeDesc[FaultID.ComputedPropertyName] = 'Computed properties'; LinterConfig.nodeDesc[FaultID.LiteralAsPropertyName] = 'String or integer literal as property name'; LinterConfig.nodeDesc[FaultID.TypeQuery] = '"typeof" operations'; - LinterConfig.nodeDesc[FaultID.TupleLiteral] = 'tuple literals'; LinterConfig.nodeDesc[FaultID.RegexLiteral] = 'regex literals'; LinterConfig.nodeDesc[FaultID.IsOperator] = '"is" operations'; LinterConfig.nodeDesc[FaultID.DestructuringParameter] = 'destructuring parameters'; @@ -175,7 +173,7 @@ export class LinterConfig { static incrementOnlyTokens: Map = new Map([ [ts.SyntaxKind.AnyKeyword, FaultID.AnyType], [ts.SyntaxKind.SymbolKeyword, FaultID.SymbolType], [ts.SyntaxKind.ThisType, FaultID.ThisType], - [ts.SyntaxKind.TupleType, FaultID.TupleType], [ts.SyntaxKind.ComputedPropertyName, FaultID.ComputedPropertyName], + [ts.SyntaxKind.ComputedPropertyName, FaultID.ComputedPropertyName], [ts.SyntaxKind.TypeQuery, FaultID.TypeQuery], [ts.SyntaxKind.DeleteExpression, FaultID.DeleteOperator], [ts.SyntaxKind.RegularExpressionLiteral, FaultID.RegexLiteral], diff --git a/linter-4.2/test/array_literals.ts.relax.json b/linter-4.2/test/array_literals.ts.relax.json index bd8629495f8736b1f36ed50de157cdf0b40da290..c20fe045d7111499122dd79cd2f4311cec12946d 100644 --- a/linter-4.2/test/array_literals.ts.relax.json +++ b/linter-4.2/test/array_literals.ts.relax.json @@ -24,11 +24,6 @@ "column": 6, "problem": "AnyType" }, - { - "line": 19, - "column": 6, - "problem": "TupleType" - }, { "line": 25, "column": 12, @@ -39,11 +34,6 @@ "column": 12, "problem": "AnyType" }, - { - "line": 27, - "column": 12, - "problem": "TupleType" - }, { "line": 32, "column": 16, @@ -59,16 +49,6 @@ "column": 8, "problem": "AnyType" }, - { - "line": 45, - "column": 8, - "problem": "TupleType" - }, - { - "line": 47, - "column": 8, - "problem": "TupleType" - }, { "line": 60, "column": 7, @@ -84,11 +64,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 78, - "column": 18, - "problem": "TupleType" - }, { "line": 97, "column": 18, @@ -99,11 +74,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 103, - "column": 18, - "problem": "TupleType" - }, { "line": 126, "column": 11, diff --git a/linter-4.2/test/array_literals.ts.strict.json b/linter-4.2/test/array_literals.ts.strict.json index f2aced3ffb50a88b207d2e34a548c2086a88565e..164ec8c7c56442f72cd7e71a113b7bdeff0aebb2 100644 --- a/linter-4.2/test/array_literals.ts.strict.json +++ b/linter-4.2/test/array_literals.ts.strict.json @@ -24,11 +24,6 @@ "column": 6, "problem": "AnyType" }, - { - "line": 19, - "column": 6, - "problem": "TupleType" - }, { "line": 25, "column": 12, @@ -39,11 +34,6 @@ "column": 12, "problem": "AnyType" }, - { - "line": 27, - "column": 12, - "problem": "TupleType" - }, { "line": 32, "column": 16, @@ -59,16 +49,6 @@ "column": 8, "problem": "AnyType" }, - { - "line": 45, - "column": 8, - "problem": "TupleType" - }, - { - "line": 47, - "column": 8, - "problem": "TupleType" - }, { "line": 60, "column": 7, @@ -89,11 +69,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 78, - "column": 18, - "problem": "TupleType" - }, { "line": 97, "column": 18, @@ -104,11 +79,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 103, - "column": 18, - "problem": "TupleType" - }, { "line": 126, "column": 11, diff --git a/linter-4.2/test/for_stmts.ts.relax.json b/linter-4.2/test/for_stmts.ts.relax.json index 290b62d75cf7ee327d4091e26cb0ad3499ed31fb..362fa94c17e81b7d8ec8e43660e5650d82b6e561 100644 --- a/linter-4.2/test/for_stmts.ts.relax.json +++ b/linter-4.2/test/for_stmts.ts.relax.json @@ -24,11 +24,6 @@ "column": 17, "problem": "ClassAsObject" }, - { - "line": 43, - "column": 18, - "problem": "TupleType" - }, { "line": 49, "column": 1, diff --git a/linter-4.2/test/for_stmts.ts.strict.json b/linter-4.2/test/for_stmts.ts.strict.json index a9d22cfd500604c4abae184b53d5825f2f00f841..ead2af3bb219786bb0e0a09be2564d1e122d8af8 100644 --- a/linter-4.2/test/for_stmts.ts.strict.json +++ b/linter-4.2/test/for_stmts.ts.strict.json @@ -24,11 +24,6 @@ "column": 17, "problem": "ClassAsObject" }, - { - "line": 43, - "column": 18, - "problem": "TupleType" - }, { "line": 44, "column": 1, diff --git a/linter-4.2/test/func_inferred_type_args.ts.relax.json b/linter-4.2/test/func_inferred_type_args.ts.relax.json index 936e366dc303bbbced0ea88966141af677d8eb03..085ce05ada77e67afaa6efa9cef5cce4787340e3 100644 --- a/linter-4.2/test/func_inferred_type_args.ts.relax.json +++ b/linter-4.2/test/func_inferred_type_args.ts.relax.json @@ -129,16 +129,6 @@ "column": 10, "problem": "ObjectTypeLiteral" }, - { - "line": 60, - "column": 17, - "problem": "TupleType" - }, - { - "line": 60, - "column": 18, - "problem": "TupleType" - }, { "line": 61, "column": 1, diff --git a/linter-4.2/test/func_inferred_type_args.ts.strict.json b/linter-4.2/test/func_inferred_type_args.ts.strict.json index 936e366dc303bbbced0ea88966141af677d8eb03..085ce05ada77e67afaa6efa9cef5cce4787340e3 100644 --- a/linter-4.2/test/func_inferred_type_args.ts.strict.json +++ b/linter-4.2/test/func_inferred_type_args.ts.strict.json @@ -129,16 +129,6 @@ "column": 10, "problem": "ObjectTypeLiteral" }, - { - "line": 60, - "column": 17, - "problem": "TupleType" - }, - { - "line": 60, - "column": 18, - "problem": "TupleType" - }, { "line": 61, "column": 1, diff --git a/linter-4.2/test/function_spread_arg.ts.relax.json b/linter-4.2/test/function_spread_arg.ts.relax.json index 2994d3fba674e9caf4b3bd97dc9c094284b07362..300f6ea4c9556e5d1629637ea9a2fa6d0b408c6c 100644 --- a/linter-4.2/test/function_spread_arg.ts.relax.json +++ b/linter-4.2/test/function_spread_arg.ts.relax.json @@ -29,11 +29,6 @@ "column": 20, "problem": "AnyType" }, - { - "line": 20, - "column": 13, - "problem": "TupleType" - }, { "line": 21, "column": 5, @@ -64,11 +59,6 @@ "column": 5, "problem": "AnyType" }, - { - "line": 75, - "column": 8, - "problem": "TupleType" - }, { "line": 87, "column": 11, diff --git a/linter-4.2/test/function_spread_arg.ts.strict.json b/linter-4.2/test/function_spread_arg.ts.strict.json index 2994d3fba674e9caf4b3bd97dc9c094284b07362..300f6ea4c9556e5d1629637ea9a2fa6d0b408c6c 100644 --- a/linter-4.2/test/function_spread_arg.ts.strict.json +++ b/linter-4.2/test/function_spread_arg.ts.strict.json @@ -29,11 +29,6 @@ "column": 20, "problem": "AnyType" }, - { - "line": 20, - "column": 13, - "problem": "TupleType" - }, { "line": 21, "column": 5, @@ -64,11 +59,6 @@ "column": 5, "problem": "AnyType" }, - { - "line": 75, - "column": 8, - "problem": "TupleType" - }, { "line": 87, "column": 11, diff --git a/linter-4.2/test/recursive_types.ts.relax.json b/linter-4.2/test/recursive_types.ts.relax.json index 9f63e9379e42239afd2f06f34694593e296a573e..b06227021f092f20110cdafb2a6d660605c2ff96 100644 --- a/linter-4.2/test/recursive_types.ts.relax.json +++ b/linter-4.2/test/recursive_types.ts.relax.json @@ -13,11 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "nodes": [ - { - "line": 77, - "column": 10, - "problem": "TupleType" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter-4.2/test/recursive_types.ts.strict.json b/linter-4.2/test/recursive_types.ts.strict.json index 9f63e9379e42239afd2f06f34694593e296a573e..b06227021f092f20110cdafb2a6d660605c2ff96 100644 --- a/linter-4.2/test/recursive_types.ts.strict.json +++ b/linter-4.2/test/recursive_types.ts.strict.json @@ -13,11 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "nodes": [ - { - "line": 77, - "column": 10, - "problem": "TupleType" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter-4.2/test/types.ts.autofix.json b/linter-4.2/test/types.ts.autofix.json index 60f1a485b0762fda9cdc4ab78cb227dfc57bd0c0..9b20d4ce0572e22fea3ed1f4714591f6354ccd9e 100644 --- a/linter-4.2/test/types.ts.autofix.json +++ b/linter-4.2/test/types.ts.autofix.json @@ -46,14 +46,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 28, - "column": 17, - "problem": "TupleType", - "autofixable": false, - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 32, "column": 16, diff --git a/linter-4.2/test/types.ts.relax.json b/linter-4.2/test/types.ts.relax.json index 3f8cffb65033d081572353c9f2cbf843dd854bcf..3e79b0764570c641ba39f7419e89f73ad4848684 100644 --- a/linter-4.2/test/types.ts.relax.json +++ b/linter-4.2/test/types.ts.relax.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 28, - "column": 17, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 32, "column": 16, diff --git a/linter-4.2/test/types.ts.strict.json b/linter-4.2/test/types.ts.strict.json index af99866faeb26685bb990a8d17fcd8f1749e331a..12701e3f2bc68cdf60f3e3956c6bcc6fb7cce2f1 100644 --- a/linter-4.2/test/types.ts.strict.json +++ b/linter-4.2/test/types.ts.strict.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 28, - "column": 17, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 32, "column": 16, diff --git a/linter-4.2/test_rules/rule13.ts b/linter-4.2/test_rules/rule13.ts deleted file mode 100644 index 9d38b7e3366a2a819785b2c29e10b05df684154a..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule13.ts +++ /dev/null @@ -1,8 +0,0 @@ - -var t: [number, string] = [3, "three"] -var n = t[0] -var s = t[1] - -let a: Object[] = [3, "three"] -let b = a[0] -let c = a[1] \ No newline at end of file diff --git a/linter-4.2/test_rules/rule13.ts.autofix.json b/linter-4.2/test_rules/rule13.ts.autofix.json deleted file mode 100644 index d82cefdf1514ba8556ea86b1f7d53834f089a305..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule13.ts.autofix.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 1, - "problem": "VarDeclaration", - "autofixable": false, - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 2, - "column": 8, - "problem": "TupleType", - "autofixable": false, - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, - { - "line": 3, - "column": 1, - "problem": "VarDeclaration", - "autofixable": false, - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 4, - "column": 1, - "problem": "VarDeclaration", - "autofixable": false, - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - } - ] -} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule13.ts.relax.json b/linter-4.2/test_rules/rule13.ts.relax.json deleted file mode 100644 index 2e8a011be1d1d0c3c2b8d8cf907746ee703b4107..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule13.ts.relax.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 8, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - } - ] -} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule13.ts.strict.json b/linter-4.2/test_rules/rule13.ts.strict.json deleted file mode 100644 index 175484d2d31a84b15277490a58ffa76bd7885a5b..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule13.ts.strict.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 1, - "problem": "VarDeclaration", - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 2, - "column": 8, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, - { - "line": 3, - "column": 1, - "problem": "VarDeclaration", - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 4, - "column": 1, - "problem": "VarDeclaration", - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - } - ] -} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts.autofix.json b/linter-4.2/test_rules/rule99.ts.autofix.json index b2639eb9742b478470719fa641a5c291905586ab..d0e33d40d1e107d76ce872fc8392b99d85140f02 100644 --- a/linter-4.2/test_rules/rule99.ts.autofix.json +++ b/linter-4.2/test_rules/rule99.ts.autofix.json @@ -1,13 +1,5 @@ { "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TupleType", - "autofixable": false, - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 6, "column": 5, diff --git a/linter-4.2/test_rules/rule99.ts.relax.json b/linter-4.2/test_rules/rule99.ts.relax.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..442888a7f760c2fecc21838118f8753ea0fc1651 100644 --- a/linter-4.2/test_rules/rule99.ts.relax.json +++ b/linter-4.2/test_rules/rule99.ts.relax.json @@ -1,12 +1,5 @@ { "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 6, "column": 5, diff --git a/linter-4.2/test_rules/rule99.ts.strict.json b/linter-4.2/test_rules/rule99.ts.strict.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..442888a7f760c2fecc21838118f8753ea0fc1651 100644 --- a/linter-4.2/test_rules/rule99.ts.strict.json +++ b/linter-4.2/test_rules/rule99.ts.strict.json @@ -1,12 +1,5 @@ { "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 6, "column": 5, diff --git a/linter/cookbook_convertor/res/recipes.rst b/linter/cookbook_convertor/res/recipes.rst index c8e2e289e1391db587194925f0806c4ac7cf61f1..22bc2c6a6d768e1ca89c8138a318e1d8935421c5 100644 --- a/linter/cookbook_convertor/res/recipes.rst +++ b/linter/cookbook_convertor/res/recipes.rst @@ -364,40 +364,6 @@ In |TS|, arrays can be declared as either ``Array`` or ``T[]``. Currently, let x: string[] = ["1", "2", "3"]; let y: string[] = ["1", "2", "3"]; // Array is not supported currently -.. _R013: - -|CB_R| #13: Use ``Object[]`` instead of tuples ----------------------------------------------- - -|CB_RULE| -~~~~~~~~~ - -Currently, |LANG| does not support tuples. You can use arrays of ``Object`` -(``Object[]``) to emulate tuples. - -|CB_BAD| -~~~~~~~~ - -.. code-block:: typescript - - var t: [number, string] = [3, "three"] - var n = t[0] - var s = t[1] - -|CB_OK| -~~~~~~~ - -.. code-block:: typescript - - let t: Object[] = [3, "three"] - let n = t[0] - let s = t[1] - -|CB_SEE| -~~~~~~~~ - -* :ref:`R013` - .. _R014: |CB_R| #14: Use ``class`` instead of a type with call signature diff --git a/linter/docs/rules/recipe13.md b/linter/docs/rules/recipe13.md deleted file mode 100644 index d7a51272784452920c14541982f19a12011276bc..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe13.md +++ /dev/null @@ -1,33 +0,0 @@ -# Use ``Object[]`` instead of tuples - -Rule ``arkts-no-tuples`` - -**Severity: error** - -Currently, ArkTS does not support tuples. Use arrays of ``Object`` -(``Object[]``) to emulate tuples. - - -## TypeScript - - -``` - - var t: [number, string] = [3, "three"] - var n = t[0] - var s = t[1] - -``` - -## ArkTS - - -``` - - let t: Object[] = [3, "three"] - let n = t[0] - let s = t[1] - -``` - - diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index 87c5dc8fff787ea98ea12ebb0887704ac3ea85af..158105ef4fa7adeb25568534cf9f4a6c6da4acba 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -32,7 +32,7 @@ cookBookTag[9] = ''; cookBookTag[10] = ''; cookBookTag[11] = ''; cookBookTag[12] = ''; -cookBookTag[13] = 'Use "Object[]" instead of tuples (arkts-no-tuples)'; +cookBookTag[13] = ''; cookBookTag[14] = 'Use "class" instead of a type with call signature (arkts-no-call-signatures)'; cookBookTag[15] = 'Use "class" instead of a type with constructor signature (arkts-no-ctor-signatures-type)'; cookBookTag[16] = 'Only one static block is supported (arkts-no-multiple-static-blocks)'; diff --git a/linter/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index bdaf14ea54f5a478048e227a613082485068dadb..a28a8c62cea80914837013afc6c8d37b2a30aee3 100644 --- a/linter/src/FaultAttrs.ts +++ b/linter/src/FaultAttrs.ts @@ -31,8 +31,6 @@ faultsAttrs[FaultID.DeclWithDuplicateName] = {migratable: true, cookBookRef: '4' faultsAttrs[FaultID.VarDeclaration] = {migratable: true, cookBookRef: '5',}; faultsAttrs[FaultID.AnyType] = {cookBookRef: '8'}; faultsAttrs[FaultID.UnknownType] = {cookBookRef: '8',}; -faultsAttrs[FaultID.TupleType] = {cookBookRef: '13',}; -faultsAttrs[FaultID.TupleLiteral] = {cookBookRef: '13',}; faultsAttrs[FaultID.CallSignature] = {cookBookRef: '14',}; faultsAttrs[FaultID.ConstructorType] = {cookBookRef: '15',}; faultsAttrs[FaultID.MultipleStaticBlocks] = {cookBookRef: '16',}; diff --git a/linter/src/FaultDesc.ts b/linter/src/FaultDesc.ts index ae0717c048282dde9f0ded22c8c5c610d3cafbcf..a96dc271def1e5f0aa838836531be731fc938b1e 100644 --- a/linter/src/FaultDesc.ts +++ b/linter/src/FaultDesc.ts @@ -19,13 +19,11 @@ export const faultDesc: string[] = []; faultDesc[FaultID.AnyType] = '"any" type'; faultDesc[FaultID.SymbolType] = '"symbol" type'; -faultDesc[FaultID.TupleType] = 'Tuple type'; faultDesc[FaultID.ObjectLiteralNoContextType] = 'Object literals with no context Class or Interface type'; faultDesc[FaultID.ArrayLiteralNoContextType] = 'Array literals with no context Array type'; faultDesc[FaultID.ComputedPropertyName] = 'Computed properties'; faultDesc[FaultID.LiteralAsPropertyName] = 'String or integer literal as property name'; faultDesc[FaultID.TypeQuery] = '"typeof" operations'; -faultDesc[FaultID.TupleLiteral] = 'tuple literals'; faultDesc[FaultID.RegexLiteral] = 'regex literals'; faultDesc[FaultID.IsOperator] = '"is" operations'; faultDesc[FaultID.DestructuringParameter] = 'destructuring parameters'; diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts index f4ac406f2ccb2f312bb7cdf6fab625ef4928c234..eb83a707a29e31b14ccedaf2fdc5887306289eba 100644 --- a/linter/src/Problems.ts +++ b/linter/src/Problems.ts @@ -14,8 +14,8 @@ */ export enum FaultID { - AnyType, SymbolType, TupleType, ObjectLiteralNoContextType, ArrayLiteralNoContextType, - ComputedPropertyName, LiteralAsPropertyName, TypeQuery, TupleLiteral, RegexLiteral, IsOperator, + AnyType, SymbolType, ObjectLiteralNoContextType, ArrayLiteralNoContextType, + ComputedPropertyName, LiteralAsPropertyName, TypeQuery, RegexLiteral, IsOperator, DestructuringParameter, YieldExpression, InterfaceMerging, EnumMerging, InterfaceExtendsClass, IndexMember, WithStatement, ThrowStatement, IndexedAccessType, UnknownType, ForInStatement, InOperator, KeyOfOperator, ImportFromPath, FunctionExpression, IntersectionType, diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index ea461af04a92274d4da8b40833635b00880d692e..416cffbddd14cb38ef6301fce623fed15eee337e 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -468,12 +468,7 @@ export class TypeScriptLinter { return; } let arrayLitNode = node as ts.ArrayLiteralExpression; - // check element types - if (ts.isUnionTypeNode(arrayLitNode)) { - this.incrementCounters(node, FaultID.TupleLiteral); - } let noContextTypeForArrayLiteral = false; - // check that array literal consists of inferrable types // e.g. there is no element which is untyped object literals let arrayLitElements = arrayLitNode.elements; diff --git a/linter/src/TypeScriptLinterConfig.ts b/linter/src/TypeScriptLinterConfig.ts index 40ce33cd1ac51da5c10ad7dcc8bdf618c47e4811..83427d5e63c20733b731268d43e9e2951a431150 100644 --- a/linter/src/TypeScriptLinterConfig.ts +++ b/linter/src/TypeScriptLinterConfig.ts @@ -74,7 +74,7 @@ export class LinterConfig { static incrementOnlyTokens: Map = new Map([ [ts.SyntaxKind.AnyKeyword, FaultID.AnyType], [ts.SyntaxKind.SymbolKeyword, FaultID.SymbolType], [ts.SyntaxKind.ThisType, FaultID.ThisType], - [ts.SyntaxKind.TupleType, FaultID.TupleType], [ts.SyntaxKind.ComputedPropertyName, FaultID.ComputedPropertyName], + [ts.SyntaxKind.ComputedPropertyName, FaultID.ComputedPropertyName], [ts.SyntaxKind.TypeQuery, FaultID.TypeQuery], [ts.SyntaxKind.DeleteExpression, FaultID.DeleteOperator], [ts.SyntaxKind.RegularExpressionLiteral, FaultID.RegexLiteral], diff --git a/linter/test/array_literals.ts.relax.json b/linter/test/array_literals.ts.relax.json index bd8629495f8736b1f36ed50de157cdf0b40da290..c20fe045d7111499122dd79cd2f4311cec12946d 100644 --- a/linter/test/array_literals.ts.relax.json +++ b/linter/test/array_literals.ts.relax.json @@ -24,11 +24,6 @@ "column": 6, "problem": "AnyType" }, - { - "line": 19, - "column": 6, - "problem": "TupleType" - }, { "line": 25, "column": 12, @@ -39,11 +34,6 @@ "column": 12, "problem": "AnyType" }, - { - "line": 27, - "column": 12, - "problem": "TupleType" - }, { "line": 32, "column": 16, @@ -59,16 +49,6 @@ "column": 8, "problem": "AnyType" }, - { - "line": 45, - "column": 8, - "problem": "TupleType" - }, - { - "line": 47, - "column": 8, - "problem": "TupleType" - }, { "line": 60, "column": 7, @@ -84,11 +64,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 78, - "column": 18, - "problem": "TupleType" - }, { "line": 97, "column": 18, @@ -99,11 +74,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 103, - "column": 18, - "problem": "TupleType" - }, { "line": 126, "column": 11, diff --git a/linter/test/array_literals.ts.strict.json b/linter/test/array_literals.ts.strict.json index f2aced3ffb50a88b207d2e34a548c2086a88565e..164ec8c7c56442f72cd7e71a113b7bdeff0aebb2 100644 --- a/linter/test/array_literals.ts.strict.json +++ b/linter/test/array_literals.ts.strict.json @@ -24,11 +24,6 @@ "column": 6, "problem": "AnyType" }, - { - "line": 19, - "column": 6, - "problem": "TupleType" - }, { "line": 25, "column": 12, @@ -39,11 +34,6 @@ "column": 12, "problem": "AnyType" }, - { - "line": 27, - "column": 12, - "problem": "TupleType" - }, { "line": 32, "column": 16, @@ -59,16 +49,6 @@ "column": 8, "problem": "AnyType" }, - { - "line": 45, - "column": 8, - "problem": "TupleType" - }, - { - "line": 47, - "column": 8, - "problem": "TupleType" - }, { "line": 60, "column": 7, @@ -89,11 +69,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 78, - "column": 18, - "problem": "TupleType" - }, { "line": 97, "column": 18, @@ -104,11 +79,6 @@ "column": 18, "problem": "AnyType" }, - { - "line": 103, - "column": 18, - "problem": "TupleType" - }, { "line": 126, "column": 11, diff --git a/linter/test/for_stmts.ts.relax.json b/linter/test/for_stmts.ts.relax.json index 290b62d75cf7ee327d4091e26cb0ad3499ed31fb..362fa94c17e81b7d8ec8e43660e5650d82b6e561 100644 --- a/linter/test/for_stmts.ts.relax.json +++ b/linter/test/for_stmts.ts.relax.json @@ -24,11 +24,6 @@ "column": 17, "problem": "ClassAsObject" }, - { - "line": 43, - "column": 18, - "problem": "TupleType" - }, { "line": 49, "column": 1, diff --git a/linter/test/for_stmts.ts.strict.json b/linter/test/for_stmts.ts.strict.json index a9d22cfd500604c4abae184b53d5825f2f00f841..ead2af3bb219786bb0e0a09be2564d1e122d8af8 100644 --- a/linter/test/for_stmts.ts.strict.json +++ b/linter/test/for_stmts.ts.strict.json @@ -24,11 +24,6 @@ "column": 17, "problem": "ClassAsObject" }, - { - "line": 43, - "column": 18, - "problem": "TupleType" - }, { "line": 44, "column": 1, diff --git a/linter/test/func_inferred_type_args.ts.relax.json b/linter/test/func_inferred_type_args.ts.relax.json index 936e366dc303bbbced0ea88966141af677d8eb03..085ce05ada77e67afaa6efa9cef5cce4787340e3 100644 --- a/linter/test/func_inferred_type_args.ts.relax.json +++ b/linter/test/func_inferred_type_args.ts.relax.json @@ -129,16 +129,6 @@ "column": 10, "problem": "ObjectTypeLiteral" }, - { - "line": 60, - "column": 17, - "problem": "TupleType" - }, - { - "line": 60, - "column": 18, - "problem": "TupleType" - }, { "line": 61, "column": 1, diff --git a/linter/test/func_inferred_type_args.ts.strict.json b/linter/test/func_inferred_type_args.ts.strict.json index 936e366dc303bbbced0ea88966141af677d8eb03..085ce05ada77e67afaa6efa9cef5cce4787340e3 100644 --- a/linter/test/func_inferred_type_args.ts.strict.json +++ b/linter/test/func_inferred_type_args.ts.strict.json @@ -129,16 +129,6 @@ "column": 10, "problem": "ObjectTypeLiteral" }, - { - "line": 60, - "column": 17, - "problem": "TupleType" - }, - { - "line": 60, - "column": 18, - "problem": "TupleType" - }, { "line": 61, "column": 1, diff --git a/linter/test/function_spread_arg.ts.relax.json b/linter/test/function_spread_arg.ts.relax.json index 2994d3fba674e9caf4b3bd97dc9c094284b07362..300f6ea4c9556e5d1629637ea9a2fa6d0b408c6c 100644 --- a/linter/test/function_spread_arg.ts.relax.json +++ b/linter/test/function_spread_arg.ts.relax.json @@ -29,11 +29,6 @@ "column": 20, "problem": "AnyType" }, - { - "line": 20, - "column": 13, - "problem": "TupleType" - }, { "line": 21, "column": 5, @@ -64,11 +59,6 @@ "column": 5, "problem": "AnyType" }, - { - "line": 75, - "column": 8, - "problem": "TupleType" - }, { "line": 87, "column": 11, diff --git a/linter/test/function_spread_arg.ts.strict.json b/linter/test/function_spread_arg.ts.strict.json index 2994d3fba674e9caf4b3bd97dc9c094284b07362..300f6ea4c9556e5d1629637ea9a2fa6d0b408c6c 100644 --- a/linter/test/function_spread_arg.ts.strict.json +++ b/linter/test/function_spread_arg.ts.strict.json @@ -29,11 +29,6 @@ "column": 20, "problem": "AnyType" }, - { - "line": 20, - "column": 13, - "problem": "TupleType" - }, { "line": 21, "column": 5, @@ -64,11 +59,6 @@ "column": 5, "problem": "AnyType" }, - { - "line": 75, - "column": 8, - "problem": "TupleType" - }, { "line": 87, "column": 11, diff --git a/linter/test/recursive_types.ts.relax.json b/linter/test/recursive_types.ts.relax.json index 9f63e9379e42239afd2f06f34694593e296a573e..b06227021f092f20110cdafb2a6d660605c2ff96 100644 --- a/linter/test/recursive_types.ts.relax.json +++ b/linter/test/recursive_types.ts.relax.json @@ -13,11 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "nodes": [ - { - "line": 77, - "column": 10, - "problem": "TupleType" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter/test/recursive_types.ts.strict.json b/linter/test/recursive_types.ts.strict.json index 9f63e9379e42239afd2f06f34694593e296a573e..b06227021f092f20110cdafb2a6d660605c2ff96 100644 --- a/linter/test/recursive_types.ts.strict.json +++ b/linter/test/recursive_types.ts.strict.json @@ -13,11 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "nodes": [ - { - "line": 77, - "column": 10, - "problem": "TupleType" - } - ] + "nodes": [] } \ No newline at end of file diff --git a/linter/test/types.ts.autofix.json b/linter/test/types.ts.autofix.json index 60f1a485b0762fda9cdc4ab78cb227dfc57bd0c0..9b20d4ce0572e22fea3ed1f4714591f6354ccd9e 100644 --- a/linter/test/types.ts.autofix.json +++ b/linter/test/types.ts.autofix.json @@ -46,14 +46,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 28, - "column": 17, - "problem": "TupleType", - "autofixable": false, - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 32, "column": 16, diff --git a/linter/test/types.ts.relax.json b/linter/test/types.ts.relax.json index 3f8cffb65033d081572353c9f2cbf843dd854bcf..3e79b0764570c641ba39f7419e89f73ad4848684 100644 --- a/linter/test/types.ts.relax.json +++ b/linter/test/types.ts.relax.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 28, - "column": 17, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 32, "column": 16, diff --git a/linter/test/types.ts.strict.json b/linter/test/types.ts.strict.json index af99866faeb26685bb990a8d17fcd8f1749e331a..12701e3f2bc68cdf60f3e3956c6bcc6fb7cce2f1 100644 --- a/linter/test/types.ts.strict.json +++ b/linter/test/types.ts.strict.json @@ -42,13 +42,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 28, - "column": 17, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 32, "column": 16, diff --git a/linter/test_rules/rule13.ts b/linter/test_rules/rule13.ts deleted file mode 100644 index 9d38b7e3366a2a819785b2c29e10b05df684154a..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule13.ts +++ /dev/null @@ -1,8 +0,0 @@ - -var t: [number, string] = [3, "three"] -var n = t[0] -var s = t[1] - -let a: Object[] = [3, "three"] -let b = a[0] -let c = a[1] \ No newline at end of file diff --git a/linter/test_rules/rule13.ts.autofix.json b/linter/test_rules/rule13.ts.autofix.json deleted file mode 100644 index d82cefdf1514ba8556ea86b1f7d53834f089a305..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule13.ts.autofix.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 1, - "problem": "VarDeclaration", - "autofixable": false, - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 2, - "column": 8, - "problem": "TupleType", - "autofixable": false, - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, - { - "line": 3, - "column": 1, - "problem": "VarDeclaration", - "autofixable": false, - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 4, - "column": 1, - "problem": "VarDeclaration", - "autofixable": false, - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule13.ts.relax.json b/linter/test_rules/rule13.ts.relax.json deleted file mode 100644 index 2e8a011be1d1d0c3c2b8d8cf907746ee703b4107..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule13.ts.relax.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 8, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule13.ts.strict.json b/linter/test_rules/rule13.ts.strict.json deleted file mode 100644 index 175484d2d31a84b15277490a58ffa76bd7885a5b..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule13.ts.strict.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 1, - "problem": "VarDeclaration", - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 2, - "column": 8, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, - { - "line": 3, - "column": 1, - "problem": "VarDeclaration", - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - }, - { - "line": 4, - "column": 1, - "problem": "VarDeclaration", - "suggest": "", - "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule99.ts.autofix.json b/linter/test_rules/rule99.ts.autofix.json index b2639eb9742b478470719fa641a5c291905586ab..d0e33d40d1e107d76ce872fc8392b99d85140f02 100644 --- a/linter/test_rules/rule99.ts.autofix.json +++ b/linter/test_rules/rule99.ts.autofix.json @@ -1,13 +1,5 @@ { "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TupleType", - "autofixable": false, - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 6, "column": 5, diff --git a/linter/test_rules/rule99.ts.relax.json b/linter/test_rules/rule99.ts.relax.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..442888a7f760c2fecc21838118f8753ea0fc1651 100644 --- a/linter/test_rules/rule99.ts.relax.json +++ b/linter/test_rules/rule99.ts.relax.json @@ -1,12 +1,5 @@ { "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 6, "column": 5, diff --git a/linter/test_rules/rule99.ts.strict.json b/linter/test_rules/rule99.ts.strict.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..442888a7f760c2fecc21838118f8753ea0fc1651 100644 --- a/linter/test_rules/rule99.ts.strict.json +++ b/linter/test_rules/rule99.ts.strict.json @@ -1,12 +1,5 @@ { "nodes": [ - { - "line": 5, - "column": 12, - "problem": "TupleType", - "suggest": "", - "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" - }, { "line": 6, "column": 5,