From 54bd5fe60e3b7ef795c93ad7d7241bd1cd4f2cd2 Mon Sep 17 00:00:00 2001 From: Redkin Mikhail Date: Mon, 4 Sep 2023 13:37:31 +0300 Subject: [PATCH] Add esobject tests Signed-off-by: Redkin Mikhail --- linter/test/esobject.ts | 75 ++++++++++++++++++++++++++++ linter/test/esobject.ts.autofix.json | 28 +++++++++++ linter/test/esobject.ts.relax.json | 25 ++++++++++ linter/test/esobject.ts.strict.json | 25 ++++++++++ 4 files changed, 153 insertions(+) create mode 100644 linter/test/esobject.ts create mode 100644 linter/test/esobject.ts.autofix.json create mode 100644 linter/test/esobject.ts.relax.json create mode 100644 linter/test/esobject.ts.strict.json diff --git a/linter/test/esobject.ts b/linter/test/esobject.ts new file mode 100644 index 000000000..4bd2116a8 --- /dev/null +++ b/linter/test/esobject.ts @@ -0,0 +1,75 @@ +import { ExecSyncOptions } from "child_process"; + +export let obj = new ESObject(); + +type t1 = ESObject +type t2 = ESObject[] + +export type t3 = ESObject +export type t4 = ESObject[] + +export type t5 = t3 +export type t6 = t[] + +export function foo1(): any { + let a: ESObject = "STRING"; + return a +} + +export function foo2(a: ESObject): ESObject { + return a; +} + +export function foo3(a: t3): t3 { + return a; +} + +foo2(5) +foo3(5) +foo2("asd") +foo3("asd") +foo2(null) +foo3(null) +foo2(undefined) +foo3(undefined) + +export function foo4(a: ESObject[]): ESObject { + return a; +} + +export function foo5(a: t3[]): t3 { + return a; +} + +foo4([2, 3]) +foo5([2, 3]) +foo4(["str1", "str2"]) +foo5(["str1", "str2"]) +let n = new ESObject[0] +n = null + +foo4(n) +foo5(n) + +export function foo6(a: ESObject[]): ESObject { + return a; +} + +export function foo7(a: t3[]): t3 { + return a; +} + +export function foo8(a: ESObject[]): ESObject { + return a; +} + +export function foo9(a: t3[]): t3 { + return a; +} + +export class Cls {} + +interface CL extends ESObject {} + +export interface CLS extends ESObject {} + diff --git a/linter/test/esobject.ts.autofix.json b/linter/test/esobject.ts.autofix.json new file mode 100644 index 000000000..9ec5f6971 --- /dev/null +++ b/linter/test/esobject.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 3, + "column": 12, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 14, + "column": 25, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 48, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter/test/esobject.ts.relax.json b/linter/test/esobject.ts.relax.json new file mode 100644 index 000000000..c7b01d349 --- /dev/null +++ b/linter/test/esobject.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 3, + "column": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 14, + "column": 25, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 48, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter/test/esobject.ts.strict.json b/linter/test/esobject.ts.strict.json new file mode 100644 index 000000000..c7b01d349 --- /dev/null +++ b/linter/test/esobject.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 3, + "column": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 14, + "column": 25, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 48, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file -- Gitee