From ca945637726601b1e6f81488521a699c8f516be5 Mon Sep 17 00:00:00 2001 From: Aleksandr Gorlov Date: Tue, 3 Oct 2023 16:37:54 +0300 Subject: [PATCH] add one more test for rule 105 Signed-off-by: Aleksandr Gorlov --- linter-4.2/test_rules/rule105_1.ts | 16 ++++++++++++++++ linter-4.2/test_rules/rule105_1.ts.autofix.json | 12 ++++++++++++ linter-4.2/test_rules/rule105_1.ts.relax.json | 11 +++++++++++ linter-4.2/test_rules/rule105_1.ts.strict.json | 11 +++++++++++ linter/test_rules/rule105_1.ts | 16 ++++++++++++++++ linter/test_rules/rule105_1.ts.autofix.json | 12 ++++++++++++ linter/test_rules/rule105_1.ts.relax.json | 11 +++++++++++ linter/test_rules/rule105_1.ts.strict.json | 11 +++++++++++ 8 files changed, 100 insertions(+) create mode 100644 linter-4.2/test_rules/rule105_1.ts create mode 100644 linter-4.2/test_rules/rule105_1.ts.autofix.json create mode 100644 linter-4.2/test_rules/rule105_1.ts.relax.json create mode 100644 linter-4.2/test_rules/rule105_1.ts.strict.json create mode 100644 linter/test_rules/rule105_1.ts create mode 100644 linter/test_rules/rule105_1.ts.autofix.json create mode 100644 linter/test_rules/rule105_1.ts.relax.json create mode 100644 linter/test_rules/rule105_1.ts.strict.json diff --git a/linter-4.2/test_rules/rule105_1.ts b/linter-4.2/test_rules/rule105_1.ts new file mode 100644 index 000000000..45c4a8327 --- /dev/null +++ b/linter-4.2/test_rules/rule105_1.ts @@ -0,0 +1,16 @@ +class A { + public fooAttr: number = 0; + public barAttr: number = 0; +} + +function getSomeObject() { + return new A() +} + +let obj: any = getSomeObject() +let obj2 = obj as A; +if (obj2 && obj2.fooAttr && obj2.barAttr) { + console.log("Yes") +} else { + console.log("No") +} diff --git a/linter-4.2/test_rules/rule105_1.ts.autofix.json b/linter-4.2/test_rules/rule105_1.ts.autofix.json new file mode 100644 index 000000000..83af4ab39 --- /dev/null +++ b/linter-4.2/test_rules/rule105_1.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} diff --git a/linter-4.2/test_rules/rule105_1.ts.relax.json b/linter-4.2/test_rules/rule105_1.ts.relax.json new file mode 100644 index 000000000..285de551d --- /dev/null +++ b/linter-4.2/test_rules/rule105_1.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} diff --git a/linter-4.2/test_rules/rule105_1.ts.strict.json b/linter-4.2/test_rules/rule105_1.ts.strict.json new file mode 100644 index 000000000..285de551d --- /dev/null +++ b/linter-4.2/test_rules/rule105_1.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} diff --git a/linter/test_rules/rule105_1.ts b/linter/test_rules/rule105_1.ts new file mode 100644 index 000000000..45c4a8327 --- /dev/null +++ b/linter/test_rules/rule105_1.ts @@ -0,0 +1,16 @@ +class A { + public fooAttr: number = 0; + public barAttr: number = 0; +} + +function getSomeObject() { + return new A() +} + +let obj: any = getSomeObject() +let obj2 = obj as A; +if (obj2 && obj2.fooAttr && obj2.barAttr) { + console.log("Yes") +} else { + console.log("No") +} diff --git a/linter/test_rules/rule105_1.ts.autofix.json b/linter/test_rules/rule105_1.ts.autofix.json new file mode 100644 index 000000000..83af4ab39 --- /dev/null +++ b/linter/test_rules/rule105_1.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} diff --git a/linter/test_rules/rule105_1.ts.relax.json b/linter/test_rules/rule105_1.ts.relax.json new file mode 100644 index 000000000..285de551d --- /dev/null +++ b/linter/test_rules/rule105_1.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} diff --git a/linter/test_rules/rule105_1.ts.strict.json b/linter/test_rules/rule105_1.ts.strict.json new file mode 100644 index 000000000..285de551d --- /dev/null +++ b/linter/test_rules/rule105_1.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} -- Gitee