diff --git a/linter-4.2/docs/rules/recipe141.md b/linter-4.2/docs/rules/recipe141.md deleted file mode 100644 index a772b5388d1033d6e2bd8711a7bd3f1956b60ec0..0000000000000000000000000000000000000000 --- a/linter-4.2/docs/rules/recipe141.md +++ /dev/null @@ -1,34 +0,0 @@ -# ``readonly T[]`` syntax is not supported - -Rule ``arkts-no-readonly-params`` - -**Severity: error** - -Currently, ArkTS supports ``readonly`` for properties, but not for parameters. - - -## TypeScript - - -``` - - function foo(arr: readonly string[]) { - arr.slice() // OK - arr.push("hello!") // Compile-time error - } - -``` - -## ArkTS - - -``` - - function foo(arr: string[]) { - arr.slice() // OK - arr.push("hello!") // OK - } - -``` - - diff --git a/linter-4.2/src/Autofixer.ts b/linter-4.2/src/Autofixer.ts index 697a71f54d8ffb4e9c4383a33dc64856c4224966..0ff724931fa23d6404eb0260b5023bc7c9295038 100644 --- a/linter-4.2/src/Autofixer.ts +++ b/linter-4.2/src/Autofixer.ts @@ -134,14 +134,6 @@ export function fixTypeAssertion(typeAssertion: ts.TypeAssertion): Autofix { return { start: typeAssertion.getStart(), end: typeAssertion.getEnd(), replacementText: text }; } -export function fixReadonlyArr(node: ts.Node): Autofix { - return { - start: node.getStart(), - end: node.getEnd(), - replacementText: node.getText().substring('readonly '.length), - }; -} - const printer: ts.Printer = ts.createPrinter(); function numericLiteral2IdentifierName(numeric: ts.NumericLiteral) { diff --git a/linter-4.2/src/CookBookMsg.ts b/linter-4.2/src/CookBookMsg.ts index 87c5dc8fff787ea98ea12ebb0887704ac3ea85af..ae282eee2d713167ae64cbc8a2b6eb16e72b8ec8 100644 --- a/linter-4.2/src/CookBookMsg.ts +++ b/linter-4.2/src/CookBookMsg.ts @@ -160,7 +160,7 @@ cookBookTag[137] = '"globalThis" is not supported (arkts-no-globalthis)'; cookBookTag[138] = 'Some of utility types are not supported (arkts-no-utility-types)'; cookBookTag[139] = 'Declaring properties on functions is not supported (arkts-no-func-props)'; cookBookTag[140] = '"Function.apply", "Function.bind", "Function.call" are not supported (arkts-no-func-apply-bind-call)'; -cookBookTag[141] = '"readonly T[]" syntax is not supported (arkts-no-readonly-params)'; +cookBookTag[141] = ''; cookBookTag[142] = '"as const" assertions are not supported (arkts-no-as-const)'; cookBookTag[143] = 'Import assertions are not supported (arkts-no-import-assertions)'; cookBookTag[144] = 'Usage of standard library is restricted (arkts-limited-stdlib)'; diff --git a/linter-4.2/src/Problems.ts b/linter-4.2/src/Problems.ts index 373f7768862f074bb310c381ed7f031759abd5d2..eaa1498287138901b0cc6cc0d745697fe89c12a9 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -32,7 +32,7 @@ export enum FaultID { GenericCallNoTypeArgs, ParameterProperties, InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition, NewTarget, DefiniteAssignment, IifeAsNamespace, Prototype, GlobalThis, - UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ReadonlyArr, ConstAssertion, ImportAssertion, + UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ConstAssertion, ImportAssertion, SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, UnsupportedDecorators, ImportAfterStatement, EsObjectType, EsObjectAssignment, EsObjectAccess, LAST_ID, // this should always be last enum` @@ -129,7 +129,6 @@ faultsAttrs[FaultID.GlobalThis] = {cookBookRef: '137',}; faultsAttrs[FaultID.UtilityType] = {cookBookRef: '138',}; faultsAttrs[FaultID.PropertyDeclOnFunction] = {cookBookRef: '139',}; faultsAttrs[FaultID.FunctionApplyBindCall] = {cookBookRef: '140',}; -faultsAttrs[FaultID.ReadonlyArr] = {migratable: true, cookBookRef: '141',}; faultsAttrs[FaultID.ConstAssertion] = {cookBookRef: '142',}; faultsAttrs[FaultID.ImportAssertion] = {cookBookRef: '143',}; faultsAttrs[FaultID.LimitedStdLibApi] = {cookBookRef: '144',}; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index c2a79bc87d4d7350fd3f530e5046ce2534d4d920..ad75b54d9357448035965ebf231a9c54cb442099 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -738,10 +738,6 @@ export class TypeScriptLinter { const fullText = node.getFullText().trim(); if (fullText.startsWith("keyof")) this.incrementCounters(node, FaultID.KeyOfOperator); - else if (fullText.startsWith("readonly")) - this.incrementCounters(node, FaultID.ReadonlyArr, true, [ - Autofixer.fixReadonlyArr(node), - ]); } private handleImportDeclaration(node: ts.Node) { diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index 1834923b6fb67f8c2ebf986468d177e1c121a9a4..02fe63f5a6ddfca0fc493487a2ba007fcf9e1fbf 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -116,7 +116,6 @@ export class LinterConfig { LinterConfig.nodeDesc[FaultID.UtilityType] = 'Standard Utility types'; LinterConfig.nodeDesc[FaultID.PropertyDeclOnFunction] = 'Property declaration on function'; LinterConfig.nodeDesc[FaultID.FunctionApplyBindCall] = 'Invoking methods of function objects'; - LinterConfig.nodeDesc[FaultID.ReadonlyArr] = '"readonly" array or tuple'; LinterConfig.nodeDesc[FaultID.ConstAssertion] = '"as const" assertion'; LinterConfig.nodeDesc[FaultID.ImportAssertion] = 'Import assertion'; LinterConfig.nodeDesc[FaultID.SpreadOperator] = 'Spread operation'; diff --git a/linter-4.2/test/readonly_arr.ts.autofix.json b/linter-4.2/test/readonly_arr.ts.autofix.json index bd3479561a3b4d5d6e5313a3a336648f9aedfd58..982cc7b6966d6abfb07137bf70365f353e0c3469 100644 --- a/linter-4.2/test/readonly_arr.ts.autofix.json +++ b/linter-4.2/test/readonly_arr.ts.autofix.json @@ -14,19 +14,6 @@ "limitations under the License." ], "nodes": [ - { - "line": 21, - "column": 19, - "problem": "ReadonlyArr", - "autofixable": true, - "autofix": [ - { - "start": 712, - "end": 729, - "replacementText": "string[]" - } - ] - }, { "line": 17, "column": 12, diff --git a/linter-4.2/test/readonly_arr.ts.strict.json b/linter-4.2/test/readonly_arr.ts.strict.json index 5f11751c532ba65de437922eeaf6f259c652dedf..ac1284435817d0f67e436555207d30f3608aa8fd 100644 --- a/linter-4.2/test/readonly_arr.ts.strict.json +++ b/linter-4.2/test/readonly_arr.ts.strict.json @@ -14,11 +14,6 @@ "limitations under the License." ], "nodes": [ - { - "line": 21, - "column": 19, - "problem": "ReadonlyArr" - }, { "line": 17, "column": 12, diff --git a/linter-4.2/test_rules/rule141.ts b/linter-4.2/test_rules/rule141.ts deleted file mode 100644 index a0ebc2f8428794c09de4b981903603faef933529..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule141.ts +++ /dev/null @@ -1,4 +0,0 @@ -function foo(arr: readonly string[]) { - arr.slice() // OK - arr.push("hello!") // Compile-time error -} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule141.ts.autofix.json b/linter-4.2/test_rules/rule141.ts.autofix.json deleted file mode 100644 index 4843ef02e483bcebe356e13659b0b744669bc658..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule141.ts.autofix.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 19, - "problem": "ReadonlyArr", - "autofixable": true, - "autofix": [ - { - "start": 18, - "end": 35, - "replacementText": "string[]" - } - ], - "suggest": "", - "rule": "\"readonly T[]\" syntax is not supported (arkts-no-readonly-params)" - } - ] -} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule141.ts.relax.json b/linter-4.2/test_rules/rule141.ts.relax.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule141.ts.relax.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule141.ts.strict.json b/linter-4.2/test_rules/rule141.ts.strict.json deleted file mode 100644 index 3d0ea495351117bd2c94275253dd750a713dc86d..0000000000000000000000000000000000000000 --- a/linter-4.2/test_rules/rule141.ts.strict.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 19, - "problem": "ReadonlyArr", - "suggest": "", - "rule": "\"readonly T[]\" syntax is not supported (arkts-no-readonly-params)" - } - ] -} \ No newline at end of file diff --git a/linter/docs/rules/recipe141.md b/linter/docs/rules/recipe141.md deleted file mode 100644 index a772b5388d1033d6e2bd8711a7bd3f1956b60ec0..0000000000000000000000000000000000000000 --- a/linter/docs/rules/recipe141.md +++ /dev/null @@ -1,34 +0,0 @@ -# ``readonly T[]`` syntax is not supported - -Rule ``arkts-no-readonly-params`` - -**Severity: error** - -Currently, ArkTS supports ``readonly`` for properties, but not for parameters. - - -## TypeScript - - -``` - - function foo(arr: readonly string[]) { - arr.slice() // OK - arr.push("hello!") // Compile-time error - } - -``` - -## ArkTS - - -``` - - function foo(arr: string[]) { - arr.slice() // OK - arr.push("hello!") // OK - } - -``` - - diff --git a/linter/src/AutofixTitles.ts b/linter/src/AutofixTitles.ts index 4059f5b4b7f0b8947f1dfa41015bcdac4371cd64..89bad0381fe8112ffdb123e32e89b96142010523 100644 --- a/linter/src/AutofixTitles.ts +++ b/linter/src/AutofixTitles.ts @@ -25,5 +25,4 @@ export const cookBookRefToFixTitle: Map = new Map([ [118, 'Replace with ordinary import'], [120, 'Replace with explicit import'], [127, 'Replace with ordinary export'], - [141, 'Remove \'readonly\' keyword'], ]); diff --git a/linter/src/Autofixer.ts b/linter/src/Autofixer.ts index 8d44c607a28cd3d12cb44b97e137ee01b764d65b..e10d1ce44519fb9e57e6952d8e5afaddcbb267f0 100644 --- a/linter/src/Autofixer.ts +++ b/linter/src/Autofixer.ts @@ -142,14 +142,6 @@ export function fixTypeAssertion(typeAssertion: ts.TypeAssertion): Autofix { return { start: typeAssertion.getStart(), end: typeAssertion.getEnd(), replacementText: text }; } -export function fixReadonlyArr(node: ts.Node): Autofix { - return { - start: node.getStart(), - end: node.getEnd(), - replacementText: node.getText().substring('readonly '.length), - }; -} - const printer: ts.Printer = ts.createPrinter(); function numericLiteral2IdentifierName(numeric: ts.NumericLiteral) { diff --git a/linter/src/CookBookMsg.ts b/linter/src/CookBookMsg.ts index 87c5dc8fff787ea98ea12ebb0887704ac3ea85af..ae282eee2d713167ae64cbc8a2b6eb16e72b8ec8 100644 --- a/linter/src/CookBookMsg.ts +++ b/linter/src/CookBookMsg.ts @@ -160,7 +160,7 @@ cookBookTag[137] = '"globalThis" is not supported (arkts-no-globalthis)'; cookBookTag[138] = 'Some of utility types are not supported (arkts-no-utility-types)'; cookBookTag[139] = 'Declaring properties on functions is not supported (arkts-no-func-props)'; cookBookTag[140] = '"Function.apply", "Function.bind", "Function.call" are not supported (arkts-no-func-apply-bind-call)'; -cookBookTag[141] = '"readonly T[]" syntax is not supported (arkts-no-readonly-params)'; +cookBookTag[141] = ''; cookBookTag[142] = '"as const" assertions are not supported (arkts-no-as-const)'; cookBookTag[143] = 'Import assertions are not supported (arkts-no-import-assertions)'; cookBookTag[144] = 'Usage of standard library is restricted (arkts-limited-stdlib)'; diff --git a/linter/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index bdaf14ea54f5a478048e227a613082485068dadb..67fabac253949193c7fa5dccaa360742f5b47840 100644 --- a/linter/src/FaultAttrs.ts +++ b/linter/src/FaultAttrs.ts @@ -106,7 +106,6 @@ faultsAttrs[FaultID.GlobalThis] = {cookBookRef: '137',}; faultsAttrs[FaultID.UtilityType] = {cookBookRef: '138',}; faultsAttrs[FaultID.PropertyDeclOnFunction] = {cookBookRef: '139',}; faultsAttrs[FaultID.FunctionApplyBindCall] = {cookBookRef: '140',}; -faultsAttrs[FaultID.ReadonlyArr] = {migratable: true, cookBookRef: '141',}; faultsAttrs[FaultID.ConstAssertion] = {cookBookRef: '142',}; faultsAttrs[FaultID.ImportAssertion] = {cookBookRef: '143',}; faultsAttrs[FaultID.LimitedStdLibApi] = {cookBookRef: '144',}; diff --git a/linter/src/FaultDesc.ts b/linter/src/FaultDesc.ts index ae0717c048282dde9f0ded22c8c5c610d3cafbcf..49141435631e380bd01dddc54e60e19144fc0de1 100644 --- a/linter/src/FaultDesc.ts +++ b/linter/src/FaultDesc.ts @@ -100,7 +100,6 @@ faultDesc[FaultID.GlobalThis] = 'Use of globalThis'; faultDesc[FaultID.UtilityType] = 'Standard Utility types'; faultDesc[FaultID.PropertyDeclOnFunction] = 'Property declaration on function'; faultDesc[FaultID.FunctionApplyBindCall] = 'Invoking methods of function objects'; -faultDesc[FaultID.ReadonlyArr] = '"readonly" array or tuple'; faultDesc[FaultID.ConstAssertion] = '"as const" assertion'; faultDesc[FaultID.ImportAssertion] = 'Import assertion'; faultDesc[FaultID.SpreadOperator] = 'Spread operation'; diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts index f4ac406f2ccb2f312bb7cdf6fab625ef4928c234..3db60b3e7db3c99750b363bfec1fdbba88a45ba8 100644 --- a/linter/src/Problems.ts +++ b/linter/src/Problems.ts @@ -32,7 +32,7 @@ export enum FaultID { GenericCallNoTypeArgs, ParameterProperties, InstanceofUnsupported, ShorthandAmbientModuleDecl, WildcardsInModuleName, UMDModuleDefinition, NewTarget, DefiniteAssignment, IifeAsNamespace, Prototype, GlobalThis, - UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ReadonlyArr, ConstAssertion, ImportAssertion, + UtilityType, PropertyDeclOnFunction, FunctionApplyBindCall, ConstAssertion, ImportAssertion, SpreadOperator, LimitedStdLibApi, ErrorSuppression, StrictDiagnostic, UnsupportedDecorators, ImportAfterStatement, EsObjectType, EsObjectAssignment, EsObjectAccess, LAST_ID, // this should always be last enum` diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index ea461af04a92274d4da8b40833635b00880d692e..6251b4a7fc4f87eae4a9ce19ef5eb81ba9654200 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -615,8 +615,6 @@ export class TypeScriptLinter { const fullText = node.getFullText().trim(); if (fullText.startsWith('keyof')) { this.incrementCounters(node, FaultID.KeyOfOperator); - } else if (fullText.startsWith('readonly')) { - this.incrementCounters(node, FaultID.ReadonlyArr, true, [ Autofixer.fixReadonlyArr(node) ]); } } diff --git a/linter/test/readonly_arr.ts.autofix.json b/linter/test/readonly_arr.ts.autofix.json index bd3479561a3b4d5d6e5313a3a336648f9aedfd58..982cc7b6966d6abfb07137bf70365f353e0c3469 100644 --- a/linter/test/readonly_arr.ts.autofix.json +++ b/linter/test/readonly_arr.ts.autofix.json @@ -14,19 +14,6 @@ "limitations under the License." ], "nodes": [ - { - "line": 21, - "column": 19, - "problem": "ReadonlyArr", - "autofixable": true, - "autofix": [ - { - "start": 712, - "end": 729, - "replacementText": "string[]" - } - ] - }, { "line": 17, "column": 12, diff --git a/linter/test/readonly_arr.ts.strict.json b/linter/test/readonly_arr.ts.strict.json index 5f11751c532ba65de437922eeaf6f259c652dedf..ac1284435817d0f67e436555207d30f3608aa8fd 100644 --- a/linter/test/readonly_arr.ts.strict.json +++ b/linter/test/readonly_arr.ts.strict.json @@ -14,11 +14,6 @@ "limitations under the License." ], "nodes": [ - { - "line": 21, - "column": 19, - "problem": "ReadonlyArr" - }, { "line": 17, "column": 12, diff --git a/linter/test_rules/rule141.ts b/linter/test_rules/rule141.ts deleted file mode 100644 index a0ebc2f8428794c09de4b981903603faef933529..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule141.ts +++ /dev/null @@ -1,4 +0,0 @@ -function foo(arr: readonly string[]) { - arr.slice() // OK - arr.push("hello!") // Compile-time error -} \ No newline at end of file diff --git a/linter/test_rules/rule141.ts.autofix.json b/linter/test_rules/rule141.ts.autofix.json deleted file mode 100644 index 4843ef02e483bcebe356e13659b0b744669bc658..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule141.ts.autofix.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 19, - "problem": "ReadonlyArr", - "autofixable": true, - "autofix": [ - { - "start": 18, - "end": 35, - "replacementText": "string[]" - } - ], - "suggest": "", - "rule": "\"readonly T[]\" syntax is not supported (arkts-no-readonly-params)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule141.ts.relax.json b/linter/test_rules/rule141.ts.relax.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule141.ts.relax.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule141.ts.strict.json b/linter/test_rules/rule141.ts.strict.json deleted file mode 100644 index 3d0ea495351117bd2c94275253dd750a713dc86d..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule141.ts.strict.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 19, - "problem": "ReadonlyArr", - "suggest": "", - "rule": "\"readonly T[]\" syntax is not supported (arkts-no-readonly-params)" - } - ] -} \ No newline at end of file