diff --git a/linter-4.2/docs/rules/recipe99.md b/linter-4.2/docs/rules/recipe99.md index 3b8fb79741d08f17a10b556e579033516d5b8798..b5c78af078d3b7d0f96f9fea490e04d68db09eea 100644 --- a/linter-4.2/docs/rules/recipe99.md +++ b/linter-4.2/docs/rules/recipe99.md @@ -1,13 +1,14 @@ -# It is possible to spread only arrays into the rest parameter +# It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals Rule ``arkts-no-spread`` **Severity: error** -The only supported scenario for the spread operator is to spread an array into -the rest parameter. Otherwise, manually "unpack" data from arrays and objects, -where necessary. All typed arrays from the standard library (for example, -``Int32Array``) are also supported. +The only supported scenario for the spread operator is to spread an array or +class derived from array into the rest parameter or array literal. +Otherwise, manually "unpack" data from arrays and objects, where necessary. +All typed arrays from the standard library (for example, ``Int32Array``) +are also supported. ## TypeScript @@ -68,6 +69,13 @@ where necessary. All typed arrays from the standard library (for example, let p3d = new Point3D({x: 1, y: 2} as Point2D, 3) console.log(p3d.x, p3d.y, p3d.z) + class DerivedFromArray extends Uint16Array {}; + + let arr1 = [1, 2, 3]; + let arr2 = new Uint16Array([4, 5, 6]); + let arr3 = new DerivedFromArray([7, 8, 9]) + let arr4 = [...arr1, 10, ...arr2, 11, ...arr3] + ``` diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index 87c5dc8fff787ea98ea12ebb0887704ac3ea85af..621eeb670a122ab65e99073ed24c55e9e71a9f9e 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -118,7 +118,7 @@ cookBookTag[95] = ''; cookBookTag[96] = 'Type guarding is supported with "instanceof" and "as" (arkts-no-is)'; cookBookTag[97] = '"keyof" operator is not supported (arkts-no-keyof)'; cookBookTag[98] = ''; -cookBookTag[99] = 'It is possible to spread only arrays into the rest parameter (arkts-no-spread)'; +cookBookTag[99] = 'It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)'; cookBookTag[100] = ''; cookBookTag[101] = ''; cookBookTag[102] = 'Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)'; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index c2a79bc87d4d7350fd3f530e5046ce2534d4d920..13dfababa5dd874f933a1997f13740a34b188647 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -2047,11 +2047,13 @@ export class TypeScriptLinter { ); if ( spreadExprTypeNode !== undefined && - ts.isCallLikeExpression(node.parent) + (ts.isCallLikeExpression(node.parent) || + ts.isArrayLiteralExpression(node.parent)) ) { if ( ts.isArrayTypeNode(spreadExprTypeNode) || - this.tsUtils.isTypedArray(spreadExprTypeNode) + this.tsUtils.isTypedArray(spreadExprTypeNode) || + this.tsUtils.isDerivedFromArray(spreadExprType) ) { return; } diff --git a/linter-4.2/test/array_literal_spread.ts b/linter-4.2/test/array_literal_spread.ts new file mode 100644 index 0000000000000000000000000000000000000000..233c2c5d7a2d0be7f7448b9e9d4399741670792f --- /dev/null +++ b/linter-4.2/test/array_literal_spread.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class DerivedFromArray extends Uint16Array { +}; + +let arr1 = [1, 2, 3]; +let arr2 = new Uint16Array([4, 5, 6]); +let arr3 = new DerivedFromArray([7, 8, 9]) + +let arr4 = [...arr1, 10, ...arr2, 11, ...arr3] diff --git a/linter-4.2/test/array_literal_spread.ts.autofix.skip b/linter-4.2/test/array_literal_spread.ts.autofix.skip new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/linter-4.2/test/array_literal_spread.ts.relax.json b/linter-4.2/test/array_literal_spread.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..b06227021f092f20110cdafb2a6d660605c2ff96 --- /dev/null +++ b/linter-4.2/test/array_literal_spread.ts.relax.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test/array_literal_spread.ts.strict.json b/linter-4.2/test/array_literal_spread.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..b06227021f092f20110cdafb2a6d660605c2ff96 --- /dev/null +++ b/linter-4.2/test/array_literal_spread.ts.strict.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test/destructuring.ts.relax.json b/linter-4.2/test/destructuring.ts.relax.json index 7053e79b9740e0c57cd12e213038dcb58d6e596d..14ae01cc1367ed0ab5c60600f74f92859351e149 100644 --- a/linter-4.2/test/destructuring.ts.relax.json +++ b/linter-4.2/test/destructuring.ts.relax.json @@ -59,11 +59,6 @@ "column": 10, "problem": "SpreadOperator" }, - { - "line": 51, - "column": 11, - "problem": "SpreadOperator" - }, { "line": 55, "column": 12, diff --git a/linter-4.2/test/destructuring.ts.strict.json b/linter-4.2/test/destructuring.ts.strict.json index 2bf3ea978f0e8f2972906b152ad2c7c3a1ca9345..0c913b11c4d7817812afc887b426d0f966901d2c 100644 --- a/linter-4.2/test/destructuring.ts.strict.json +++ b/linter-4.2/test/destructuring.ts.strict.json @@ -84,11 +84,6 @@ "column": 10, "problem": "SpreadOperator" }, - { - "line": 51, - "column": 11, - "problem": "SpreadOperator" - }, { "line": 55, "column": 12, diff --git a/linter-4.2/test_rules/rule69.ts.autofix.json b/linter-4.2/test_rules/rule69.ts.autofix.json index 0c8f1f91d0f533625f3f90f90c8e26bb254ba9f5..647cff3bbd0f9f2eba09d8d60600f7b18844464b 100644 --- a/linter-4.2/test_rules/rule69.ts.autofix.json +++ b/linter-4.2/test_rules/rule69.ts.autofix.json @@ -46,7 +46,7 @@ "problem": "SpreadOperator", "autofixable": false, "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule69.ts.relax.json b/linter-4.2/test_rules/rule69.ts.relax.json index 740d7e2ea0f467d656ea296acf68136f61cf483a..683feccb8d9c123fcd04289b30c2762c69d98ed9 100644 --- a/linter-4.2/test_rules/rule69.ts.relax.json +++ b/linter-4.2/test_rules/rule69.ts.relax.json @@ -19,7 +19,7 @@ "column": 8, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule69.ts.strict.json b/linter-4.2/test_rules/rule69.ts.strict.json index d09d39688d644d94b43a277ee72b9c66553f0ed9..eb5a79b2a4d88eeccd771f14de87346ca5a8baf4 100644 --- a/linter-4.2/test_rules/rule69.ts.strict.json +++ b/linter-4.2/test_rules/rule69.ts.strict.json @@ -40,7 +40,7 @@ "column": 8, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts b/linter-4.2/test_rules/rule99.ts index 61f72c85a8b3a2c0eddaa92e6977de9290e21fbf..aa9b0f100cda6b96b780c8042badc7d83459be29 100644 --- a/linter-4.2/test_rules/rule99.ts +++ b/linter-4.2/test_rules/rule99.ts @@ -45,4 +45,13 @@ class Point3D { } let p3d = new Point3D({x: 1, y: 2} as Point2D, 3) -console.log(p3d.x, p3d.y, p3d.z) \ No newline at end of file +console.log(p3d.x, p3d.y, p3d.z) + +class DerivedFromArray extends Uint16Array { +}; + +let arr1 = [1, 2, 3]; +let arr2 = new Uint16Array([4, 5, 6]); +let arr3 = new DerivedFromArray([7, 8, 9]) + +let arr4 = [...arr1, 10, ...arr2, 11, ...arr3] diff --git a/linter-4.2/test_rules/rule99.ts.autofix.json b/linter-4.2/test_rules/rule99.ts.autofix.json index b2639eb9742b478470719fa641a5c291905586ab..35f8ae0dea10f91dd2d5b05c0b6882e43d339f08 100644 --- a/linter-4.2/test_rules/rule99.ts.autofix.json +++ b/linter-4.2/test_rules/rule99.ts.autofix.json @@ -14,15 +14,7 @@ "problem": "SpreadOperator", "autofixable": false, "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" - }, - { - "line": 9, - "column": 14, - "problem": "SpreadOperator", - "autofixable": false, - "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" }, { "line": 11, @@ -46,7 +38,7 @@ "problem": "SpreadOperator", "autofixable": false, "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts.relax.json b/linter-4.2/test_rules/rule99.ts.relax.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..21a12fd105d2587d949642558027df5841885ea2 100644 --- a/linter-4.2/test_rules/rule99.ts.relax.json +++ b/linter-4.2/test_rules/rule99.ts.relax.json @@ -12,14 +12,7 @@ "column": 5, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" - }, - { - "line": 9, - "column": 14, - "problem": "SpreadOperator", - "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" }, { "line": 11, @@ -40,7 +33,7 @@ "column": 16, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts.strict.json b/linter-4.2/test_rules/rule99.ts.strict.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..21a12fd105d2587d949642558027df5841885ea2 100644 --- a/linter-4.2/test_rules/rule99.ts.strict.json +++ b/linter-4.2/test_rules/rule99.ts.strict.json @@ -12,14 +12,7 @@ "column": 5, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" - }, - { - "line": 9, - "column": 14, - "problem": "SpreadOperator", - "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" }, { "line": 11, @@ -40,7 +33,7 @@ "column": 16, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter/docs/rules/recipe99.md b/linter/docs/rules/recipe99.md index 3b8fb79741d08f17a10b556e579033516d5b8798..b5c78af078d3b7d0f96f9fea490e04d68db09eea 100644 --- a/linter/docs/rules/recipe99.md +++ b/linter/docs/rules/recipe99.md @@ -1,13 +1,14 @@ -# It is possible to spread only arrays into the rest parameter +# It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals Rule ``arkts-no-spread`` **Severity: error** -The only supported scenario for the spread operator is to spread an array into -the rest parameter. Otherwise, manually "unpack" data from arrays and objects, -where necessary. All typed arrays from the standard library (for example, -``Int32Array``) are also supported. +The only supported scenario for the spread operator is to spread an array or +class derived from array into the rest parameter or array literal. +Otherwise, manually "unpack" data from arrays and objects, where necessary. +All typed arrays from the standard library (for example, ``Int32Array``) +are also supported. ## TypeScript @@ -68,6 +69,13 @@ where necessary. All typed arrays from the standard library (for example, let p3d = new Point3D({x: 1, y: 2} as Point2D, 3) console.log(p3d.x, p3d.y, p3d.z) + class DerivedFromArray extends Uint16Array {}; + + let arr1 = [1, 2, 3]; + let arr2 = new Uint16Array([4, 5, 6]); + let arr3 = new DerivedFromArray([7, 8, 9]) + let arr4 = [...arr1, 10, ...arr2, 11, ...arr3] + ``` diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index 87c5dc8fff787ea98ea12ebb0887704ac3ea85af..621eeb670a122ab65e99073ed24c55e9e71a9f9e 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -118,7 +118,7 @@ cookBookTag[95] = ''; cookBookTag[96] = 'Type guarding is supported with "instanceof" and "as" (arkts-no-is)'; cookBookTag[97] = '"keyof" operator is not supported (arkts-no-keyof)'; cookBookTag[98] = ''; -cookBookTag[99] = 'It is possible to spread only arrays into the rest parameter (arkts-no-spread)'; +cookBookTag[99] = 'It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)'; cookBookTag[100] = ''; cookBookTag[101] = ''; cookBookTag[102] = 'Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)'; diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index ea461af04a92274d4da8b40833635b00880d692e..a2f70aae4969823a6233a2e1fea8321423d4e2c0 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -1654,8 +1654,9 @@ export class TypeScriptLinter { let spreadExprType = this.tsTypeChecker.getTypeAtLocation(spreadElemNode.expression); if (spreadExprType) { const spreadExprTypeNode = this.tsTypeChecker.typeToTypeNode(spreadExprType, undefined, ts.NodeBuilderFlags.None); - if (spreadExprTypeNode !== undefined && ts.isCallLikeExpression(node.parent)) { - if (ts.isArrayTypeNode(spreadExprTypeNode) || this.tsUtils.isTypedArray(spreadExprTypeNode)) { + if (spreadExprTypeNode !== undefined && (ts.isCallLikeExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) { + if (ts.isArrayTypeNode(spreadExprTypeNode) || this.tsUtils.isTypedArray(spreadExprTypeNode) || + this.tsUtils.isDerivedFromArray(spreadExprType)) { return } } diff --git a/linter/test/array_literal_spread.ts b/linter/test/array_literal_spread.ts new file mode 100644 index 0000000000000000000000000000000000000000..233c2c5d7a2d0be7f7448b9e9d4399741670792f --- /dev/null +++ b/linter/test/array_literal_spread.ts @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class DerivedFromArray extends Uint16Array { +}; + +let arr1 = [1, 2, 3]; +let arr2 = new Uint16Array([4, 5, 6]); +let arr3 = new DerivedFromArray([7, 8, 9]) + +let arr4 = [...arr1, 10, ...arr2, 11, ...arr3] diff --git a/linter/test/array_literal_spread.ts.autofix.skip b/linter/test/array_literal_spread.ts.autofix.skip new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/linter/test/array_literal_spread.ts.relax.json b/linter/test/array_literal_spread.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..b06227021f092f20110cdafb2a6d660605c2ff96 --- /dev/null +++ b/linter/test/array_literal_spread.ts.relax.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [] +} \ No newline at end of file diff --git a/linter/test/array_literal_spread.ts.strict.json b/linter/test/array_literal_spread.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..b06227021f092f20110cdafb2a6d660605c2ff96 --- /dev/null +++ b/linter/test/array_literal_spread.ts.strict.json @@ -0,0 +1,17 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [] +} \ No newline at end of file diff --git a/linter/test/destructuring.ts.relax.json b/linter/test/destructuring.ts.relax.json index 7053e79b9740e0c57cd12e213038dcb58d6e596d..14ae01cc1367ed0ab5c60600f74f92859351e149 100644 --- a/linter/test/destructuring.ts.relax.json +++ b/linter/test/destructuring.ts.relax.json @@ -59,11 +59,6 @@ "column": 10, "problem": "SpreadOperator" }, - { - "line": 51, - "column": 11, - "problem": "SpreadOperator" - }, { "line": 55, "column": 12, diff --git a/linter/test/destructuring.ts.strict.json b/linter/test/destructuring.ts.strict.json index 2bf3ea978f0e8f2972906b152ad2c7c3a1ca9345..0c913b11c4d7817812afc887b426d0f966901d2c 100644 --- a/linter/test/destructuring.ts.strict.json +++ b/linter/test/destructuring.ts.strict.json @@ -84,11 +84,6 @@ "column": 10, "problem": "SpreadOperator" }, - { - "line": 51, - "column": 11, - "problem": "SpreadOperator" - }, { "line": 55, "column": 12, diff --git a/linter/test_rules/rule69.ts.autofix.json b/linter/test_rules/rule69.ts.autofix.json index 0c8f1f91d0f533625f3f90f90c8e26bb254ba9f5..647cff3bbd0f9f2eba09d8d60600f7b18844464b 100644 --- a/linter/test_rules/rule69.ts.autofix.json +++ b/linter/test_rules/rule69.ts.autofix.json @@ -46,7 +46,7 @@ "problem": "SpreadOperator", "autofixable": false, "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule69.ts.relax.json b/linter/test_rules/rule69.ts.relax.json index 740d7e2ea0f467d656ea296acf68136f61cf483a..683feccb8d9c123fcd04289b30c2762c69d98ed9 100644 --- a/linter/test_rules/rule69.ts.relax.json +++ b/linter/test_rules/rule69.ts.relax.json @@ -19,7 +19,7 @@ "column": 8, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule69.ts.strict.json b/linter/test_rules/rule69.ts.strict.json index d09d39688d644d94b43a277ee72b9c66553f0ed9..eb5a79b2a4d88eeccd771f14de87346ca5a8baf4 100644 --- a/linter/test_rules/rule69.ts.strict.json +++ b/linter/test_rules/rule69.ts.strict.json @@ -40,7 +40,7 @@ "column": 8, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule99.ts b/linter/test_rules/rule99.ts index 61f72c85a8b3a2c0eddaa92e6977de9290e21fbf..aa9b0f100cda6b96b780c8042badc7d83459be29 100644 --- a/linter/test_rules/rule99.ts +++ b/linter/test_rules/rule99.ts @@ -45,4 +45,13 @@ class Point3D { } let p3d = new Point3D({x: 1, y: 2} as Point2D, 3) -console.log(p3d.x, p3d.y, p3d.z) \ No newline at end of file +console.log(p3d.x, p3d.y, p3d.z) + +class DerivedFromArray extends Uint16Array { +}; + +let arr1 = [1, 2, 3]; +let arr2 = new Uint16Array([4, 5, 6]); +let arr3 = new DerivedFromArray([7, 8, 9]) + +let arr4 = [...arr1, 10, ...arr2, 11, ...arr3] diff --git a/linter/test_rules/rule99.ts.autofix.json b/linter/test_rules/rule99.ts.autofix.json index b2639eb9742b478470719fa641a5c291905586ab..35f8ae0dea10f91dd2d5b05c0b6882e43d339f08 100644 --- a/linter/test_rules/rule99.ts.autofix.json +++ b/linter/test_rules/rule99.ts.autofix.json @@ -14,15 +14,7 @@ "problem": "SpreadOperator", "autofixable": false, "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" - }, - { - "line": 9, - "column": 14, - "problem": "SpreadOperator", - "autofixable": false, - "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" }, { "line": 11, @@ -46,7 +38,7 @@ "problem": "SpreadOperator", "autofixable": false, "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule99.ts.relax.json b/linter/test_rules/rule99.ts.relax.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..21a12fd105d2587d949642558027df5841885ea2 100644 --- a/linter/test_rules/rule99.ts.relax.json +++ b/linter/test_rules/rule99.ts.relax.json @@ -12,14 +12,7 @@ "column": 5, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" - }, - { - "line": 9, - "column": 14, - "problem": "SpreadOperator", - "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" }, { "line": 11, @@ -40,7 +33,7 @@ "column": 16, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule99.ts.strict.json b/linter/test_rules/rule99.ts.strict.json index df5204fcfef2b49fc8e76bb7e97d0184c1f78336..21a12fd105d2587d949642558027df5841885ea2 100644 --- a/linter/test_rules/rule99.ts.strict.json +++ b/linter/test_rules/rule99.ts.strict.json @@ -12,14 +12,7 @@ "column": 5, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" - }, - { - "line": 9, - "column": 14, - "problem": "SpreadOperator", - "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" }, { "line": 11, @@ -40,7 +33,7 @@ "column": 16, "problem": "SpreadOperator", "suggest": "", - "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + "rule": "It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread)" } ] } \ No newline at end of file