From 2cf6753e14f5529ab05df3d4698a021523157e2e Mon Sep 17 00:00:00 2001 From: Nazarov Konstantin Date: Tue, 9 Jan 2024 09:32:16 +0000 Subject: [PATCH] Revert 'Pull Request !95 : [ArkTS Linter] fix#14863 (number literals as interface proprty signatures names)' --- linter-4.2/src/TypeScriptLinter.ts | 16 +++++++++------- .../test/literals_as_prop_names.ts.strict.json | 7 ------- linter-4.2/test/types.ts.strict.json | 7 ------- linter-4.2/test_rules/rule1.ts | 5 ----- linter-4.2/test_rules/rule1.ts.autofix.json | 8 -------- linter-4.2/test_rules/rule1.ts.strict.json | 7 ------- linter/lib/TypeScriptLinter.ts | 10 ++++++---- .../test/literals_as_prop_names.ts.strict.json | 7 ------- linter/test/types.ts.strict.json | 7 ------- linter/test_rules/rule1.ts | 4 ---- linter/test_rules/rule1.ts.autofix.json | 8 -------- linter/test_rules/rule1.ts.strict.json | 7 ------- 12 files changed, 15 insertions(+), 78 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 8e4a10f1..19c44c13 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -757,10 +757,12 @@ export class TypeScriptLinter { } private handlePropertySignature(node: ts.PropertySignature): void { - const propName = node.name; - if (!!propName && ts.isNumericLiteral(propName)) { - this.incrementCounters(node, FaultID.LiteralAsPropertyName, ); - } + + /** + * Handler in case any further restrictions are put on properties of interfaces + */ + void this; + void node; } private filterOutDecoratorsDiagnostics( @@ -2057,7 +2059,7 @@ export class TypeScriptLinter { } private handleGetAccessor(node: ts.Node) { - + /** * Reserved if needed */ @@ -2066,7 +2068,7 @@ export class TypeScriptLinter { } private handleSetAccessor(node: ts.Node) { - + /** * Reserved if needed */ @@ -2101,7 +2103,7 @@ export class TypeScriptLinter { // option is enabled, compiler attempts to infer type from variable references: // see https://github.com/microsoft/TypeScript/pull/11263. // In this case, we still want to report the error, since ArkTS doesn't allow - // to omit both type annotation and initializer. + // to omit both type annotation and initializer. if (((ts.isVariableDeclaration(decl) && ts.isVariableStatement(decl.parent.parent)) || ts.isPropertyDeclaration(decl)) && !decl.initializer) { this.incrementCounters(decl, FaultID.AnyType); diff --git a/linter-4.2/test/literals_as_prop_names.ts.strict.json b/linter-4.2/test/literals_as_prop_names.ts.strict.json index 96feeb09..40de3a10 100644 --- a/linter-4.2/test/literals_as_prop_names.ts.strict.json +++ b/linter-4.2/test/literals_as_prop_names.ts.strict.json @@ -84,13 +84,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 67, - "column": 3, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, { "line": 34, "column": 11, diff --git a/linter-4.2/test/types.ts.strict.json b/linter-4.2/test/types.ts.strict.json index 0be6ecd0..31431c27 100644 --- a/linter-4.2/test/types.ts.strict.json +++ b/linter-4.2/test/types.ts.strict.json @@ -98,13 +98,6 @@ "suggest": "", "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" }, - { - "line": 56, - "column": 3, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, { "line": 57, "column": 3, diff --git a/linter-4.2/test_rules/rule1.ts b/linter-4.2/test_rules/rule1.ts index fea7f2cb..0a37d2e6 100644 --- a/linter-4.2/test_rules/rule1.ts +++ b/linter-4.2/test_rules/rule1.ts @@ -39,8 +39,3 @@ const a2: A2 = { S1["s1"]; S2["s2"]; - - -interface I { - 2: number; -} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule1.ts.autofix.json b/linter-4.2/test_rules/rule1.ts.autofix.json index 170b37dc..d6f3182b 100644 --- a/linter-4.2/test_rules/rule1.ts.autofix.json +++ b/linter-4.2/test_rules/rule1.ts.autofix.json @@ -85,14 +85,6 @@ "autofixable": false, "suggest": "", "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, - { - "line": 45, - "column": 3, - "problem": "LiteralAsPropertyName", - "autofixable": false, - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" } ] } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule1.ts.strict.json b/linter-4.2/test_rules/rule1.ts.strict.json index 1fd9a452..2f185ba3 100644 --- a/linter-4.2/test_rules/rule1.ts.strict.json +++ b/linter-4.2/test_rules/rule1.ts.strict.json @@ -62,13 +62,6 @@ "problem": "ComputedPropertyName", "suggest": "", "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, - { - "line": 45, - "column": 3, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" } ] } \ No newline at end of file diff --git a/linter/lib/TypeScriptLinter.ts b/linter/lib/TypeScriptLinter.ts index 78a15684..98728997 100644 --- a/linter/lib/TypeScriptLinter.ts +++ b/linter/lib/TypeScriptLinter.ts @@ -752,10 +752,12 @@ export class TypeScriptLinter { } private handlePropertySignature(node: ts.PropertySignature): void { - const propName = node.name; - if (!!propName && ts.isNumericLiteral(propName)) { - this.incrementCounters(node, FaultID.LiteralAsPropertyName, ); - } + + /** + * Handler in case any further restrictions are put on properties of interfaces + */ + void this; + void node; } private filterOutDecoratorsDiagnostics( diff --git a/linter/test/literals_as_prop_names.ts.strict.json b/linter/test/literals_as_prop_names.ts.strict.json index 96feeb09..40de3a10 100644 --- a/linter/test/literals_as_prop_names.ts.strict.json +++ b/linter/test/literals_as_prop_names.ts.strict.json @@ -84,13 +84,6 @@ "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, - { - "line": 67, - "column": 3, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, { "line": 34, "column": 11, diff --git a/linter/test/types.ts.strict.json b/linter/test/types.ts.strict.json index 0be6ecd0..31431c27 100644 --- a/linter/test/types.ts.strict.json +++ b/linter/test/types.ts.strict.json @@ -98,13 +98,6 @@ "suggest": "", "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" }, - { - "line": 56, - "column": 3, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, { "line": 57, "column": 3, diff --git a/linter/test_rules/rule1.ts b/linter/test_rules/rule1.ts index 3e6e04ac..0a37d2e6 100644 --- a/linter/test_rules/rule1.ts +++ b/linter/test_rules/rule1.ts @@ -39,7 +39,3 @@ const a2: A2 = { S1["s1"]; S2["s2"]; - -interface I { - 2: number; -} \ No newline at end of file diff --git a/linter/test_rules/rule1.ts.autofix.json b/linter/test_rules/rule1.ts.autofix.json index ab1eb2fb..d6f3182b 100644 --- a/linter/test_rules/rule1.ts.autofix.json +++ b/linter/test_rules/rule1.ts.autofix.json @@ -85,14 +85,6 @@ "autofixable": false, "suggest": "", "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, - { - "line": 44, - "column": 3, - "problem": "LiteralAsPropertyName", - "autofixable": false, - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule1.ts.strict.json b/linter/test_rules/rule1.ts.strict.json index 272db883..2f185ba3 100644 --- a/linter/test_rules/rule1.ts.strict.json +++ b/linter/test_rules/rule1.ts.strict.json @@ -62,13 +62,6 @@ "problem": "ComputedPropertyName", "suggest": "", "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" - }, - { - "line": 44, - "column": 3, - "problem": "LiteralAsPropertyName", - "suggest": "", - "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" } ] } \ No newline at end of file -- Gitee