From 6e8049434df699f600bae58d6177d8fd97db427a Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Mon, 18 Sep 2023 17:48:26 +0300 Subject: [PATCH] [ArkTS Linter] #13600: Relax prototype assignment when base expression comes from interop. Change-Id: I8f023c0366a15250cb5959e5e96db1d38d9bb053 Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/TypeScriptLinter.ts | 10 ++ linter-4.2/test/prototype_assignment.ts | 5 + .../test/prototype_assignment.ts.autofix.json | 164 ++++++++++++------ .../test/prototype_assignment.ts.relax.json | 139 ++++++++++----- .../test/prototype_assignment.ts.strict.json | 163 +++++++++++------ linter/src/TypeScriptLinter.ts | 11 ++ linter/test/prototype_assignment.ts | 5 + .../test/prototype_assignment.ts.autofix.json | 164 ++++++++++++------ .../test/prototype_assignment.ts.relax.json | 139 ++++++++++----- .../test/prototype_assignment.ts.strict.json | 163 +++++++++++------ 10 files changed, 667 insertions(+), 296 deletions(-) diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index 5fe2f80a4..31058c53b 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -436,6 +436,16 @@ export class TypeScriptLinter { ) return false; + // #13600: Relax prototype check when expression comes from interop. + let curPropAccess: ts.Node = tsPropertyAccess; + while (curPropAccess && ts.isPropertyAccessExpression(curPropAccess)) { + const baseExprSym = this.tsUtils.trueSymbolAtLocation(curPropAccess.expression); + if (this.tsUtils.isLibrarySymbol(baseExprSym)) { + return false; + } + curPropAccess = curPropAccess.expression; + } + // Check if property symbol is 'Prototype' const propAccessSym = this.tsUtils.trueSymbolAtLocation(tsPropertyAccess); if (this.tsUtils.isPrototypeSymbol(propAccessSym)) return true; diff --git a/linter-4.2/test/prototype_assignment.ts b/linter-4.2/test/prototype_assignment.ts index f1510b7eb..9eba43bac 100644 --- a/linter-4.2/test/prototype_assignment.ts +++ b/linter-4.2/test/prototype_assignment.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +import { C, f } from './dynamic_lib'; + function f1() { const funProto = function (p) { this.p = p; @@ -53,3 +55,6 @@ function f2() { const yProto = Y.prototype; new Y().prototype = 10; // Not a problem } + +C.prototype.a = {}; +let b = f.prototype.prototype.b; \ No newline at end of file diff --git a/linter-4.2/test/prototype_assignment.ts.autofix.json b/linter-4.2/test/prototype_assignment.ts.autofix.json index ca852403d..024d3375c 100644 --- a/linter-4.2/test/prototype_assignment.ts.autofix.json +++ b/linter-4.2/test/prototype_assignment.ts.autofix.json @@ -15,160 +15,220 @@ ], "nodes": [ { - "line": 16, + "line": 18, "column": 1, "problem": "FunctionContainsThis", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 20, "problem": "FunctionExpression", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 17, + "line": 19, "column": 20, "problem": "FunctionContainsThis", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 30, "problem": "AnyType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 21, + "line": 23, "column": 12, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 21, + "line": 23, "column": 24, "problem": "ObjectLiteralNoContextType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 27, + "line": 29, "column": 12, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 27, + "line": 29, "column": 26, "problem": "FunctionExpression", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 27, + "line": 29, "column": 26, "problem": "FunctionContainsThis", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 27, + "line": 29, "column": 36, "problem": "AnyType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 31, + "line": 33, "column": 3, "problem": "LocalFunction", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 34, + "line": 36, "column": 7, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 34, + "line": 36, "column": 19, "problem": "ObjectLiteralNoContextType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 35, + "line": 37, "column": 17, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 7, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 29, "problem": "ObjectLiteralNoContextType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 36, + "line": 38, "column": 9, "problem": "AnyType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 38, "column": 25, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 39, + "line": 41, "column": 22, "problem": "ClassExpression", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 42, + "line": 44, "column": 14, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 51, + "line": 53, "column": 5, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 52, + "line": 54, "column": 5, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 55, "column": 20, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 60, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 40, + "line": 42, "column": 5, "problem": "StrictDiagnostic", - "autofixable": false + "autofixable": false, + "suggest": "Property 'p' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 47, + "line": 49, "column": 3, "problem": "StrictDiagnostic", - "autofixable": false + "autofixable": false, + "suggest": "Property 'prototype' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 48, + "line": 50, "column": 3, "problem": "StrictDiagnostic", - "autofixable": false + "autofixable": false, + "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'xy' has no initializer and is not definitely assigned in the constructor." } ] } \ No newline at end of file diff --git a/linter-4.2/test/prototype_assignment.ts.relax.json b/linter-4.2/test/prototype_assignment.ts.relax.json index 09783aaf9..265d993b9 100644 --- a/linter-4.2/test/prototype_assignment.ts.relax.json +++ b/linter-4.2/test/prototype_assignment.ts.relax.json @@ -15,114 +15,165 @@ ], "nodes": [ { - "line": 16, + "line": 18, "column": 1, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 20, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 30, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 21, + "line": 23, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 21, + "line": 23, "column": 24, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 27, + "line": 29, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 27, + "line": 29, "column": 26, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 27, + "line": 29, "column": 36, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 34, + "line": 36, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 34, + "line": 36, "column": 19, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 35, + "line": 37, "column": 17, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 29, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 36, + "line": 38, "column": 9, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 38, "column": 25, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 42, + "line": 44, "column": 14, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 51, + "line": 53, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 52, + "line": 54, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 55, "column": 20, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 40, + "line": 60, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 42, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'p' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 47, + "line": 49, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'prototype' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 48, + "line": 50, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'xy' has no initializer and is not definitely assigned in the constructor." } ] } \ No newline at end of file diff --git a/linter-4.2/test/prototype_assignment.ts.strict.json b/linter-4.2/test/prototype_assignment.ts.strict.json index 52a5b06fa..6390ccded 100644 --- a/linter-4.2/test/prototype_assignment.ts.strict.json +++ b/linter-4.2/test/prototype_assignment.ts.strict.json @@ -15,134 +15,193 @@ ], "nodes": [ { - "line": 16, + "line": 18, "column": 1, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 20, - "problem": "FunctionExpression" + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 17, + "line": 19, "column": 20, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 30, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 21, + "line": 23, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 21, + "line": 23, "column": 24, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 27, + "line": 29, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 27, + "line": 29, "column": 26, - "problem": "FunctionExpression" + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 27, + "line": 29, "column": 26, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 27, + "line": 29, "column": 36, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 31, + "line": 33, "column": 3, - "problem": "LocalFunction" + "problem": "LocalFunction", + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 34, + "line": 36, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 34, + "line": 36, "column": 19, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 35, + "line": 37, "column": 17, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 29, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 36, + "line": 38, "column": 9, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 38, "column": 25, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 39, + "line": 41, "column": 22, - "problem": "ClassExpression" + "problem": "ClassExpression", + "suggest": "", + "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 42, + "line": 44, "column": 14, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 51, + "line": 53, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 52, + "line": 54, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 55, "column": 20, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 40, + "line": 60, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 42, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'p' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 47, + "line": 49, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'prototype' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 48, + "line": 50, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'xy' has no initializer and is not definitely assigned in the constructor." } ] } \ No newline at end of file diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 84cba26f7..f9615df05 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -369,6 +369,17 @@ export class TypeScriptLinter { if (!(ts.isIdentifier(tsPropertyAccess.name) && tsPropertyAccess.name.text === 'prototype')) { return false; } + + // #13600: Relax prototype check when expression comes from interop. + let curPropAccess: ts.Node = tsPropertyAccess; + while (curPropAccess && ts.isPropertyAccessExpression(curPropAccess)) { + const baseExprSym = this.tsUtils.trueSymbolAtLocation(curPropAccess.expression); + if (this.tsUtils.isLibrarySymbol(baseExprSym)) { + return false; + } + curPropAccess = curPropAccess.expression; + } + // Check if property symbol is 'Prototype' const propAccessSym = this.tsUtils.trueSymbolAtLocation(tsPropertyAccess); if (this.tsUtils.isPrototypeSymbol(propAccessSym)) { diff --git a/linter/test/prototype_assignment.ts b/linter/test/prototype_assignment.ts index f1510b7eb..9eba43bac 100644 --- a/linter/test/prototype_assignment.ts +++ b/linter/test/prototype_assignment.ts @@ -13,6 +13,8 @@ * limitations under the License. */ +import { C, f } from './dynamic_lib'; + function f1() { const funProto = function (p) { this.p = p; @@ -53,3 +55,6 @@ function f2() { const yProto = Y.prototype; new Y().prototype = 10; // Not a problem } + +C.prototype.a = {}; +let b = f.prototype.prototype.b; \ No newline at end of file diff --git a/linter/test/prototype_assignment.ts.autofix.json b/linter/test/prototype_assignment.ts.autofix.json index ca852403d..024d3375c 100755 --- a/linter/test/prototype_assignment.ts.autofix.json +++ b/linter/test/prototype_assignment.ts.autofix.json @@ -15,160 +15,220 @@ ], "nodes": [ { - "line": 16, + "line": 18, "column": 1, "problem": "FunctionContainsThis", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 20, "problem": "FunctionExpression", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 17, + "line": 19, "column": 20, "problem": "FunctionContainsThis", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 30, "problem": "AnyType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 21, + "line": 23, "column": 12, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 21, + "line": 23, "column": 24, "problem": "ObjectLiteralNoContextType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 27, + "line": 29, "column": 12, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 27, + "line": 29, "column": 26, "problem": "FunctionExpression", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 27, + "line": 29, "column": 26, "problem": "FunctionContainsThis", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 27, + "line": 29, "column": 36, "problem": "AnyType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 31, + "line": 33, "column": 3, "problem": "LocalFunction", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 34, + "line": 36, "column": 7, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 34, + "line": 36, "column": 19, "problem": "ObjectLiteralNoContextType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 35, + "line": 37, "column": 17, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 7, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 29, "problem": "ObjectLiteralNoContextType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 36, + "line": 38, "column": 9, "problem": "AnyType", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 38, "column": 25, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 39, + "line": 41, "column": 22, "problem": "ClassExpression", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 42, + "line": 44, "column": 14, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 51, + "line": 53, "column": 5, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 52, + "line": 54, "column": 5, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 55, "column": 20, "problem": "Prototype", - "autofixable": false + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 60, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 40, + "line": 42, "column": 5, "problem": "StrictDiagnostic", - "autofixable": false + "autofixable": false, + "suggest": "Property 'p' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 47, + "line": 49, "column": 3, "problem": "StrictDiagnostic", - "autofixable": false + "autofixable": false, + "suggest": "Property 'prototype' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 48, + "line": 50, "column": 3, "problem": "StrictDiagnostic", - "autofixable": false + "autofixable": false, + "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'xy' has no initializer and is not definitely assigned in the constructor." } ] } \ No newline at end of file diff --git a/linter/test/prototype_assignment.ts.relax.json b/linter/test/prototype_assignment.ts.relax.json index 09783aaf9..265d993b9 100644 --- a/linter/test/prototype_assignment.ts.relax.json +++ b/linter/test/prototype_assignment.ts.relax.json @@ -15,114 +15,165 @@ ], "nodes": [ { - "line": 16, + "line": 18, "column": 1, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 20, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 30, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 21, + "line": 23, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 21, + "line": 23, "column": 24, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 27, + "line": 29, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 27, + "line": 29, "column": 26, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 27, + "line": 29, "column": 36, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 34, + "line": 36, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 34, + "line": 36, "column": 19, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 35, + "line": 37, "column": 17, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 29, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 36, + "line": 38, "column": 9, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 38, "column": 25, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 42, + "line": 44, "column": 14, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 51, + "line": 53, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 52, + "line": 54, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 55, "column": 20, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 40, + "line": 60, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 42, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'p' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 47, + "line": 49, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'prototype' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 48, + "line": 50, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'xy' has no initializer and is not definitely assigned in the constructor." } ] } \ No newline at end of file diff --git a/linter/test/prototype_assignment.ts.strict.json b/linter/test/prototype_assignment.ts.strict.json index 52a5b06fa..6390ccded 100644 --- a/linter/test/prototype_assignment.ts.strict.json +++ b/linter/test/prototype_assignment.ts.strict.json @@ -15,134 +15,193 @@ ], "nodes": [ { - "line": 16, + "line": 18, "column": 1, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 20, - "problem": "FunctionExpression" + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 17, + "line": 19, "column": 20, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 17, + "line": 19, "column": 30, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 21, + "line": 23, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 21, + "line": 23, "column": 24, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 27, + "line": 29, "column": 12, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 27, + "line": 29, "column": 26, - "problem": "FunctionExpression" + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 27, + "line": 29, "column": 26, - "problem": "FunctionContainsThis" + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 27, + "line": 29, "column": 36, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 31, + "line": 33, "column": 3, - "problem": "LocalFunction" + "problem": "LocalFunction", + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 34, + "line": 36, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 34, + "line": 36, "column": 19, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 35, + "line": 37, "column": 17, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 7, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 35, + "line": 37, "column": 29, - "problem": "ObjectLiteralNoContextType" + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 36, + "line": 38, "column": 9, - "problem": "AnyType" + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 38, "column": 25, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 39, + "line": 41, "column": 22, - "problem": "ClassExpression" + "problem": "ClassExpression", + "suggest": "", + "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 42, + "line": 44, "column": 14, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 51, + "line": 53, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 52, + "line": 54, "column": 5, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 55, "column": 20, - "problem": "Prototype" + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 40, + "line": 60, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 42, "column": 5, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'p' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 47, + "line": 49, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'prototype' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 48, + "line": 50, "column": 3, - "problem": "StrictDiagnostic" + "problem": "StrictDiagnostic", + "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'xy' has no initializer and is not definitely assigned in the constructor." } ] } \ No newline at end of file -- Gitee