diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 8e4a10f1f09af35778d128c21098f7c670152f99..19c44c13d3cd4382fb2847dde3bce61238537374 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 96feeb09ac3172f8594eee753ee070378634485d..40de3a10c25edf794dab5192b156b3ab15720fe1 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 0be6ecd0d17495c948b41b84d9838e0d8dcb8d76..31431c270701dd29d6a757f203ada3f488a2dd26 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 fea7f2cbec86d5bd2e12311d828ff1b7958a21a9..0a37d2e6d970b4d1b1214d7d759686fad3268e6f 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 170b37dcd7e91d10ea17338efad7eca454968209..d6f3182b519658612887f6d672cfa63b60d64801 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 1fd9a452adf10a9df38c2eae3ce92ca33f1409e1..2f185ba3ad655e26fbf84729f8cd1b37b6bdd5a7 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 78a156848d0be6661877b35fb99f6c16d52bf106..98728997805be1aeda35adf10b9020fc87232d82 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 96feeb09ac3172f8594eee753ee070378634485d..40de3a10c25edf794dab5192b156b3ab15720fe1 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 0be6ecd0d17495c948b41b84d9838e0d8dcb8d76..31431c270701dd29d6a757f203ada3f488a2dd26 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 3e6e04ac34cb46cb5d6b1d307769d15b591fb871..0a37d2e6d970b4d1b1214d7d759686fad3268e6f 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 ab1eb2fb30945efc682cc3bb2db3d91d26ba6a7f..d6f3182b519658612887f6d672cfa63b60d64801 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 272db883eeb414975afcf2da63d6b55a375d60dd..2f185ba3ad655e26fbf84729f8cd1b37b6bdd5a7 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