From 6c568989d98c067b5aa9d433478236c888d006b6 Mon Sep 17 00:00:00 2001 From: Evgeniy Okolnov Date: Wed, 20 Sep 2023 00:45:09 +0300 Subject: [PATCH] [ArkTS Linter] #13628: Allow prototype assignments for objects imported from 'js' modules. Change-Id: I331f9168dd14ae8c49f9ca8b4f404264975c59f9 Signed-off-by: Evgeniy Okolnov --- linter-4.2/src/CompilerWrapper.ts | 2 +- linter-4.2/src/Utils.ts | 2 +- linter-4.2/test/js_lib.js | 4 ++ linter-4.2/test/prototype_assignment.ts | 6 +- .../test/prototype_assignment.ts.autofix.json | 62 +++++++++++-------- .../test/prototype_assignment.ts.relax.json | 53 +++++++++------- .../test/prototype_assignment.ts.strict.json | 61 ++++++++++-------- linter/src/ts-compiler/FormTscOptions.ts | 2 +- linter/src/utils/TsUtils.ts | 2 +- linter/test/js_lib.js | 4 ++ linter/test/prototype_assignment.ts | 6 +- .../test/prototype_assignment.ts.autofix.json | 62 +++++++++++-------- .../test/prototype_assignment.ts.relax.json | 53 +++++++++------- .../test/prototype_assignment.ts.strict.json | 61 ++++++++++-------- 14 files changed, 220 insertions(+), 160 deletions(-) create mode 100644 linter-4.2/test/js_lib.js create mode 100644 linter/test/js_lib.js diff --git a/linter-4.2/src/CompilerWrapper.ts b/linter-4.2/src/CompilerWrapper.ts index 080906125..fd1ed25e9 100644 --- a/linter-4.2/src/CompilerWrapper.ts +++ b/linter-4.2/src/CompilerWrapper.ts @@ -57,7 +57,7 @@ function formTscOptions(cmdOptions: CommandLineOptions, extraOptions?: any): ts. let options: ts.CreateProgramOptions = { rootNames: cmdOptions.inputFiles, - options: { target: ts.ScriptTarget.Latest, module: ts.ModuleKind.CommonJS, }, + options: { target: ts.ScriptTarget.Latest, module: ts.ModuleKind.CommonJS, checkJs: true }, }; if (extraOptions) { diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index ff0ae137d..de28f6437 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -1124,7 +1124,7 @@ export class TsUtils { // We disable such behavior for *.ts files in the test mode due to lack of 'ets' // extension support. let isOhModule = pathContainsDirectory(path.normalize(fileName), 'oh_modules'); - let isInterop = srcFile.isDeclarationFile || isOhModule; + let isInterop = srcFile.isDeclarationFile || isOhModule || this.getScriptKind(srcFile) === ts.ScriptKind.JS; if (!this.testMode) { isInterop ||= this.getScriptKind(srcFile) === ts.ScriptKind.TS; } diff --git a/linter-4.2/test/js_lib.js b/linter-4.2/test/js_lib.js new file mode 100644 index 000000000..3d6bdd8ca --- /dev/null +++ b/linter-4.2/test/js_lib.js @@ -0,0 +1,4 @@ +export class Cjs { + a; +} +export function fjs() {} \ No newline at end of file diff --git a/linter-4.2/test/prototype_assignment.ts b/linter-4.2/test/prototype_assignment.ts index 9eba43bac..8bdebf6b5 100644 --- a/linter-4.2/test/prototype_assignment.ts +++ b/linter-4.2/test/prototype_assignment.ts @@ -14,6 +14,7 @@ */ import { C, f } from './dynamic_lib'; +import { Cjs, fjs } from './js_lib' function f1() { const funProto = function (p) { @@ -57,4 +58,7 @@ function f2() { } C.prototype.a = {}; -let b = f.prototype.prototype.b; \ No newline at end of file +let b = f.prototype.prototype.b; + +Cjs.prototype.a = {}; +let c = fjs.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 024d3375c..010f95481 100644 --- a/linter-4.2/test/prototype_assignment.ts.autofix.json +++ b/linter-4.2/test/prototype_assignment.ts.autofix.json @@ -15,7 +15,7 @@ ], "nodes": [ { - "line": 18, + "line": 19, "column": 1, "problem": "FunctionContainsThis", "autofixable": false, @@ -23,7 +23,7 @@ "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionExpression", "autofixable": false, @@ -31,7 +31,7 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionContainsThis", "autofixable": false, @@ -39,7 +39,7 @@ "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 30, "problem": "AnyType", "autofixable": false, @@ -47,7 +47,7 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 23, + "line": 24, "column": 12, "problem": "Prototype", "autofixable": false, @@ -55,7 +55,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 23, + "line": 24, "column": 24, "problem": "ObjectLiteralNoContextType", "autofixable": false, @@ -63,7 +63,7 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 29, + "line": 30, "column": 12, "problem": "Prototype", "autofixable": false, @@ -71,7 +71,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionExpression", "autofixable": false, @@ -79,7 +79,7 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionContainsThis", "autofixable": false, @@ -87,7 +87,7 @@ "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 29, + "line": 30, "column": 36, "problem": "AnyType", "autofixable": false, @@ -95,7 +95,7 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 33, + "line": 34, "column": 3, "problem": "LocalFunction", "autofixable": false, @@ -103,7 +103,7 @@ "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 36, + "line": 37, "column": 7, "problem": "Prototype", "autofixable": false, @@ -111,7 +111,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 36, + "line": 37, "column": 19, "problem": "ObjectLiteralNoContextType", "autofixable": false, @@ -119,7 +119,7 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 37, + "line": 38, "column": 17, "problem": "Prototype", "autofixable": false, @@ -127,7 +127,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 7, "problem": "Prototype", "autofixable": false, @@ -135,7 +135,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 29, "problem": "ObjectLiteralNoContextType", "autofixable": false, @@ -143,7 +143,7 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 38, + "line": 39, "column": 9, "problem": "AnyType", "autofixable": false, @@ -151,7 +151,7 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 38, + "line": 39, "column": 25, "problem": "Prototype", "autofixable": false, @@ -159,7 +159,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 41, + "line": 42, "column": 22, "problem": "ClassExpression", "autofixable": false, @@ -167,7 +167,7 @@ "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 44, + "line": 45, "column": 14, "problem": "Prototype", "autofixable": false, @@ -175,7 +175,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 54, "column": 5, "problem": "Prototype", "autofixable": false, @@ -183,7 +183,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 54, + "line": 55, "column": 5, "problem": "Prototype", "autofixable": false, @@ -191,7 +191,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 55, + "line": 56, "column": 20, "problem": "Prototype", "autofixable": false, @@ -199,7 +199,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 60, + "line": 61, "column": 5, "problem": "AnyType", "autofixable": false, @@ -207,7 +207,15 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 42, + "line": 64, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 43, "column": 5, "problem": "StrictDiagnostic", "autofixable": false, @@ -215,7 +223,7 @@ "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 49, + "line": 50, "column": 3, "problem": "StrictDiagnostic", "autofixable": false, @@ -223,7 +231,7 @@ "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 50, + "line": 51, "column": 3, "problem": "StrictDiagnostic", "autofixable": false, diff --git a/linter-4.2/test/prototype_assignment.ts.relax.json b/linter-4.2/test/prototype_assignment.ts.relax.json index 265d993b9..1becfaa67 100644 --- a/linter-4.2/test/prototype_assignment.ts.relax.json +++ b/linter-4.2/test/prototype_assignment.ts.relax.json @@ -15,161 +15,168 @@ ], "nodes": [ { - "line": 18, + "line": 19, "column": 1, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 30, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 23, + "line": 24, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 23, + "line": 24, "column": 24, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 29, + "line": 30, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 29, + "line": 30, "column": 36, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 37, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 36, + "line": 37, "column": 19, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 37, + "line": 38, "column": 17, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 29, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 38, + "line": 39, "column": 9, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 38, + "line": 39, "column": 25, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 44, + "line": 45, "column": 14, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 54, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 54, + "line": 55, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 55, + "line": 56, "column": 20, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 60, + "line": 61, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 64, "column": 5, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 42, + "line": 43, "column": 5, "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": 49, + "line": 50, "column": 3, "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": 50, + "line": 51, "column": 3, "problem": "StrictDiagnostic", "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", diff --git a/linter-4.2/test/prototype_assignment.ts.strict.json b/linter-4.2/test/prototype_assignment.ts.strict.json index 6390ccded..cbe8d61a7 100644 --- a/linter-4.2/test/prototype_assignment.ts.strict.json +++ b/linter-4.2/test/prototype_assignment.ts.strict.json @@ -15,189 +15,196 @@ ], "nodes": [ { - "line": 18, + "line": 19, "column": 1, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 30, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 23, + "line": 24, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 23, + "line": 24, "column": 24, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 29, + "line": 30, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 29, + "line": 30, "column": 36, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 33, + "line": 34, "column": 3, "problem": "LocalFunction", "suggest": "", "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 36, + "line": 37, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 36, + "line": 37, "column": 19, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 37, + "line": 38, "column": 17, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 29, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 38, + "line": 39, "column": 9, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 38, + "line": 39, "column": 25, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 41, + "line": 42, "column": 22, "problem": "ClassExpression", "suggest": "", "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 44, + "line": 45, "column": 14, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 54, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 54, + "line": 55, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 55, + "line": 56, "column": 20, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 60, + "line": 61, "column": 5, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 42, + "line": 64, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 43, "column": 5, "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": 49, + "line": 50, "column": 3, "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": 50, + "line": 51, "column": 3, "problem": "StrictDiagnostic", "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", diff --git a/linter/src/ts-compiler/FormTscOptions.ts b/linter/src/ts-compiler/FormTscOptions.ts index 9a1a264a3..7b89e3593 100644 --- a/linter/src/ts-compiler/FormTscOptions.ts +++ b/linter/src/ts-compiler/FormTscOptions.ts @@ -31,7 +31,7 @@ export function formTscOptions(cmdOptions: CommandLineOptions, extraOptions?: an } let options: ts.CreateProgramOptions = { rootNames: cmdOptions.inputFiles, - options: { target: ts.ScriptTarget.Latest, module: ts.ModuleKind.CommonJS, }, + options: { target: ts.ScriptTarget.Latest, module: ts.ModuleKind.CommonJS, checkJs: true }, }; if (extraOptions) { options.options = Object.assign(options.options, extraOptions); diff --git a/linter/src/utils/TsUtils.ts b/linter/src/utils/TsUtils.ts index 4fb6f6c3b..8883ebf5a 100644 --- a/linter/src/utils/TsUtils.ts +++ b/linter/src/utils/TsUtils.ts @@ -932,7 +932,7 @@ export class TsUtils { // We disable such behavior for *.ts files in the test mode due to lack of 'ets' // extension support. let isOhModule = pathContainsDirectory(path.normalize(fileName), 'oh_modules'); - let isInterop = srcFile.isDeclarationFile || isOhModule; + let isInterop = srcFile.isDeclarationFile || isOhModule || getScriptKind(srcFile) === ts.ScriptKind.JS; if (!this.testMode) { isInterop ||= getScriptKind(srcFile) === ts.ScriptKind.TS; } diff --git a/linter/test/js_lib.js b/linter/test/js_lib.js new file mode 100644 index 000000000..3d6bdd8ca --- /dev/null +++ b/linter/test/js_lib.js @@ -0,0 +1,4 @@ +export class Cjs { + a; +} +export function fjs() {} \ No newline at end of file diff --git a/linter/test/prototype_assignment.ts b/linter/test/prototype_assignment.ts index 9eba43bac..8bdebf6b5 100644 --- a/linter/test/prototype_assignment.ts +++ b/linter/test/prototype_assignment.ts @@ -14,6 +14,7 @@ */ import { C, f } from './dynamic_lib'; +import { Cjs, fjs } from './js_lib' function f1() { const funProto = function (p) { @@ -57,4 +58,7 @@ function f2() { } C.prototype.a = {}; -let b = f.prototype.prototype.b; \ No newline at end of file +let b = f.prototype.prototype.b; + +Cjs.prototype.a = {}; +let c = fjs.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 024d3375c..010f95481 100755 --- a/linter/test/prototype_assignment.ts.autofix.json +++ b/linter/test/prototype_assignment.ts.autofix.json @@ -15,7 +15,7 @@ ], "nodes": [ { - "line": 18, + "line": 19, "column": 1, "problem": "FunctionContainsThis", "autofixable": false, @@ -23,7 +23,7 @@ "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionExpression", "autofixable": false, @@ -31,7 +31,7 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionContainsThis", "autofixable": false, @@ -39,7 +39,7 @@ "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 30, "problem": "AnyType", "autofixable": false, @@ -47,7 +47,7 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 23, + "line": 24, "column": 12, "problem": "Prototype", "autofixable": false, @@ -55,7 +55,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 23, + "line": 24, "column": 24, "problem": "ObjectLiteralNoContextType", "autofixable": false, @@ -63,7 +63,7 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 29, + "line": 30, "column": 12, "problem": "Prototype", "autofixable": false, @@ -71,7 +71,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionExpression", "autofixable": false, @@ -79,7 +79,7 @@ "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionContainsThis", "autofixable": false, @@ -87,7 +87,7 @@ "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 29, + "line": 30, "column": 36, "problem": "AnyType", "autofixable": false, @@ -95,7 +95,7 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 33, + "line": 34, "column": 3, "problem": "LocalFunction", "autofixable": false, @@ -103,7 +103,7 @@ "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 36, + "line": 37, "column": 7, "problem": "Prototype", "autofixable": false, @@ -111,7 +111,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 36, + "line": 37, "column": 19, "problem": "ObjectLiteralNoContextType", "autofixable": false, @@ -119,7 +119,7 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 37, + "line": 38, "column": 17, "problem": "Prototype", "autofixable": false, @@ -127,7 +127,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 7, "problem": "Prototype", "autofixable": false, @@ -135,7 +135,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 29, "problem": "ObjectLiteralNoContextType", "autofixable": false, @@ -143,7 +143,7 @@ "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 38, + "line": 39, "column": 9, "problem": "AnyType", "autofixable": false, @@ -151,7 +151,7 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 38, + "line": 39, "column": 25, "problem": "Prototype", "autofixable": false, @@ -159,7 +159,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 41, + "line": 42, "column": 22, "problem": "ClassExpression", "autofixable": false, @@ -167,7 +167,7 @@ "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 44, + "line": 45, "column": 14, "problem": "Prototype", "autofixable": false, @@ -175,7 +175,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 54, "column": 5, "problem": "Prototype", "autofixable": false, @@ -183,7 +183,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 54, + "line": 55, "column": 5, "problem": "Prototype", "autofixable": false, @@ -191,7 +191,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 55, + "line": 56, "column": 20, "problem": "Prototype", "autofixable": false, @@ -199,7 +199,7 @@ "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 60, + "line": 61, "column": 5, "problem": "AnyType", "autofixable": false, @@ -207,7 +207,15 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 42, + "line": 64, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 43, "column": 5, "problem": "StrictDiagnostic", "autofixable": false, @@ -215,7 +223,7 @@ "rule": "Property 'p' has no initializer and is not definitely assigned in the constructor." }, { - "line": 49, + "line": 50, "column": 3, "problem": "StrictDiagnostic", "autofixable": false, @@ -223,7 +231,7 @@ "rule": "Property 'prototype' has no initializer and is not definitely assigned in the constructor." }, { - "line": 50, + "line": 51, "column": 3, "problem": "StrictDiagnostic", "autofixable": false, diff --git a/linter/test/prototype_assignment.ts.relax.json b/linter/test/prototype_assignment.ts.relax.json index 265d993b9..1becfaa67 100644 --- a/linter/test/prototype_assignment.ts.relax.json +++ b/linter/test/prototype_assignment.ts.relax.json @@ -15,161 +15,168 @@ ], "nodes": [ { - "line": 18, + "line": 19, "column": 1, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 30, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 23, + "line": 24, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 23, + "line": 24, "column": 24, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 29, + "line": 30, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 29, + "line": 30, "column": 36, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 36, + "line": 37, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 36, + "line": 37, "column": 19, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 37, + "line": 38, "column": 17, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 29, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 38, + "line": 39, "column": 9, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 38, + "line": 39, "column": 25, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 44, + "line": 45, "column": 14, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 54, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 54, + "line": 55, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 55, + "line": 56, "column": 20, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 60, + "line": 61, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 64, "column": 5, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 42, + "line": 43, "column": 5, "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": 49, + "line": 50, "column": 3, "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": 50, + "line": 51, "column": 3, "problem": "StrictDiagnostic", "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", diff --git a/linter/test/prototype_assignment.ts.strict.json b/linter/test/prototype_assignment.ts.strict.json index 6390ccded..cbe8d61a7 100644 --- a/linter/test/prototype_assignment.ts.strict.json +++ b/linter/test/prototype_assignment.ts.strict.json @@ -15,189 +15,196 @@ ], "nodes": [ { - "line": 18, + "line": 19, "column": 1, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 19, + "line": 20, "column": 20, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 19, + "line": 20, "column": 30, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 23, + "line": 24, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 23, + "line": 24, "column": 24, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 29, + "line": 30, "column": 12, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" }, { - "line": 29, + "line": 30, "column": 26, "problem": "FunctionContainsThis", "suggest": "", "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" }, { - "line": 29, + "line": 30, "column": 36, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 33, + "line": 34, "column": 3, "problem": "LocalFunction", "suggest": "", "rule": "Nested functions are not supported (arkts-no-nested-funcs)" }, { - "line": 36, + "line": 37, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 36, + "line": 37, "column": 19, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 37, + "line": 38, "column": 17, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 7, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 37, + "line": 38, "column": 29, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" }, { - "line": 38, + "line": 39, "column": 9, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 38, + "line": 39, "column": 25, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 41, + "line": 42, "column": 22, "problem": "ClassExpression", "suggest": "", "rule": "Class literals are not supported (arkts-no-class-literals)" }, { - "line": 44, + "line": 45, "column": 14, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 53, + "line": 54, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 54, + "line": 55, "column": 5, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 55, + "line": 56, "column": 20, "problem": "Prototype", "suggest": "", "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" }, { - "line": 60, + "line": 61, "column": 5, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, { - "line": 42, + "line": 64, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 43, "column": 5, "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": 49, + "line": 50, "column": 3, "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": 50, + "line": 51, "column": 3, "problem": "StrictDiagnostic", "suggest": "Property 'xy' has no initializer and is not definitely assigned in the constructor.", -- Gitee