diff --git a/linter/lib/autofixes/AutofixTitles.ts b/linter/lib/autofixes/AutofixTitles.ts index 91b7ff1f02e3bd961088772b450e8096f8f71685..67f2f396cf14e0cbd20bfaa22fd610c47dcf8692 100644 --- a/linter/lib/autofixes/AutofixTitles.ts +++ b/linter/lib/autofixes/AutofixTitles.ts @@ -22,7 +22,5 @@ export const cookBookRefToFixTitle: Map = new Map([ [79, 'Remove type annotation'], [87, 'Wrap in \'Error\''], [90, 'Annotate return type'], - [118, 'Replace with ordinary import'], - [120, 'Replace with explicit import'], - [127, 'Replace with ordinary export'] + [120, 'Replace with explicit import'] ]); diff --git a/linter/test_rules/rule109.ts b/linter/test_rules/rule109.ts deleted file mode 100644 index f059bcfd6f2fab0016796269283d2dec96485f3d..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule109.ts +++ /dev/null @@ -1,12 +0,0 @@ -class Person { - name: string = "" - age: number = 0; // semicolon is required here - [key: string]: string | number -} - -const person: Person = { - name: "John", - age: 30, - email: "john@example.com", - phone: 1234567890, -} \ No newline at end of file diff --git a/linter/test_rules/rule109.ts.relax.json b/linter/test_rules/rule109.ts.relax.json deleted file mode 100644 index 4e3cec02be669841d7f114cdc0e323a5dda3afa4..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule109.ts.relax.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "nodes": [ - { - "line": 4, - "column": 5, - "problem": "IndexMember", - "suggest": "", - "rule": "Indexed signatures are not supported (arkts-no-indexed-signatures)" - }, - { - "line": 7, - "column": 24, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule109.ts.strict.json b/linter/test_rules/rule109.ts.strict.json deleted file mode 100644 index 4e3cec02be669841d7f114cdc0e323a5dda3afa4..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule109.ts.strict.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "nodes": [ - { - "line": 4, - "column": 5, - "problem": "IndexMember", - "suggest": "", - "rule": "Indexed signatures are not supported (arkts-no-indexed-signatures)" - }, - { - "line": 7, - "column": 24, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule118.ts b/linter/test_rules/rule118.ts deleted file mode 100644 index d8fcc327ce966c558cead70ce89f70cea8e04fef..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule118.ts +++ /dev/null @@ -1,5 +0,0 @@ - // Re-using the same import - import { APIResponseType } from "api" - - // Explicitly use import type - import type { APIResponseType } from "api" \ No newline at end of file diff --git a/linter/test_rules/rule118.ts.autofix.json b/linter/test_rules/rule118.ts.autofix.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule118.ts.autofix.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule118.ts.relax.json b/linter/test_rules/rule118.ts.relax.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule118.ts.relax.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule118.ts.strict.json b/linter/test_rules/rule118.ts.strict.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule118.ts.strict.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule127.ts b/linter/test_rules/rule127.ts deleted file mode 100644 index 903d61a6dc86bd3de2df6ecfdb721d7701af6194..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule127.ts +++ /dev/null @@ -1,12 +0,0 @@ - // Explicitly exported class: - export class Class1 { - // ... - } - - // Declared class later exported through export type ... - class Class2 { - // ... - } - - // This is not supported: - export type { Class2 } \ No newline at end of file diff --git a/linter/test_rules/rule127.ts.autofix.json b/linter/test_rules/rule127.ts.autofix.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule127.ts.autofix.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule127.ts.relax.json b/linter/test_rules/rule127.ts.relax.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule127.ts.relax.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule127.ts.strict.json b/linter/test_rules/rule127.ts.strict.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule127.ts.strict.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule133.ts b/linter/test_rules/rule133.ts deleted file mode 100644 index 255d5b5b738e649aa4e3223f0ae72d78a9dac444..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule133.ts +++ /dev/null @@ -1 +0,0 @@ -const zipUtil = await import("utils/create-zip-file") \ No newline at end of file diff --git a/linter/test_rules/rule133.ts.autofix.json b/linter/test_rules/rule133.ts.autofix.json deleted file mode 100644 index 932f141fbf8ea2d779f0ae07b11d76224491673a..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule133.ts.autofix.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 7, - "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_rules/rule133.ts.relax.json b/linter/test_rules/rule133.ts.relax.json deleted file mode 100644 index a15ec7e8730a8879739797ced7d2c348f715fc94..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule133.ts.relax.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 7, - "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_rules/rule133.ts.strict.json b/linter/test_rules/rule133.ts.strict.json deleted file mode 100644 index a15ec7e8730a8879739797ced7d2c348f715fc94..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule133.ts.strict.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 7, - "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_rules/rule144.ts b/linter/test_rules/rule144.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0213de3b393291674d76f750d8f818bcfe3f3de --- /dev/null +++ b/linter/test_rules/rule144.ts @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/// Global +eval('console.log("foo")'); +let inf = Infinity; +let nan = NaN; +isFinite(1); +isNaN(2); +parseFloat('3'); +parseInt('4', 10); +encodeURI(''); +encodeURIComponent(''); +decodeURI(''); +decodeURIComponent(''); +escape(''); +unescape(''); + +global.eval('console.log("foo")'); +globalThis.eval('console.log("foo")'); +const evl = "eval('console.log(1)')"; +const res: void = Function(evl)(); +const arr1 = ['foo', 'foo', 'foo']; + +class C {} +let c = new C(); +interface Obj { + a: string; + b: number; + c: boolean; +} +const object1: Obj = { + a: 'somestring', + b: 42, + c: false, +}; + +/// Object +//Object.__proto__(), +//Object.__defineGetter__(), +//Object.__defineSetter__(); +//Object.__lookupGetter__(); +//Object.__lookupSetter__(); +Object.assign(c, c); +Object.create(c); +Object.defineProperties(c, {}); +Object.defineProperty(c, 'p', c); +Object.entries([]); +Object.freeze(() => {}); +Object.fromEntries([]); +Object.getOwnPropertyDescriptor(c, 'p'); +Object.getOwnPropertyDescriptors(c); +Object.getOwnPropertySymbols(c); +Object.getPrototypeOf(c); +Object.hasOwnProperty('p'); +Object.is(c, c); +Object.isExtensible(c); +Object.isFrozen(c); +Object.isPrototypeOf(c); +Object.isSealed(c); +Object.preventExtensions(c); +Object.propertyIsEnumerable('p'); +Object.seal(c); +Object.setPrototypeOf(c, c); +console.log(Object.getOwnPropertyNames(object1)); +console.log(Object.hasOwn(object1, 'a')); +console.log(Object.hasOwn(object1, 'toString')); +console.log(Object.keys(object1)); +console.log(Object.values(object1)); +console.log(Object.entries(object1)); + +/// Reflect +Reflect.apply(() => {}, c, []); +Reflect.construct(C, []); +Reflect.defineProperty(c, 'p', {}); +Reflect.deleteProperty(c, 'p', ); +Reflect.get(c, 'p'); +Reflect.getOwnPropertyDescriptor(c, 'p'); +Reflect.getPrototypeOf(c); +Reflect.isExtensible(c); +Reflect.preventExtensions(c); +Reflect.setPrototypeOf(c, c); +console.log(Reflect.has(object1, 'a')); +console.log(Reflect.has(object1, 'toString')); +console.log(Reflect.get(object1, 'a')); +console.log(Reflect.get(object1, 'd')); +console.log(Reflect.ownKeys(object1)); +Reflect.set(object1, 'b', 43); +Reflect.set(arr1, 2, 'bar'); + +/// Proxy +let handler: ProxyHandler = {}; +if (handler.apply) handler.apply(c, c, []); +if (handler.construct) handler.construct(c, [], () => {}); +if (handler.defineProperty) handler.defineProperty(c, "prop", {}); +if (handler.deleteProperty) handler.deleteProperty(c, "prop"); +if (handler.get) handler.get(c, "prop", {}); +if (handler.getOwnPropertyDescriptor) handler.getOwnPropertyDescriptor(c, "prop"); +if (handler.getPrototypeOf) handler.getPrototypeOf(c); +if (handler.has) handler.has(c, "prop"); +if (handler.isExtensible) handler.isExtensible(c); +if (handler.ownKeys) handler.ownKeys(c); +if (handler.preventExtensions) handler.preventExtensions(c); +if (handler.set) handler.set(c, "prop", 1, c); +if (handler.setPrototypeOf) handler.setPrototypeOf(c, null); + +/// Array +ArrayBuffer.isView({}); +let a: number[] = []; +let b = new ArrayBuffer(1); +Array.isArray(a); diff --git a/linter/test_rules/rule144.ts.autofix.skip b/linter/test_rules/rule144.ts.autofix.skip new file mode 100644 index 0000000000000000000000000000000000000000..08f902699b1857c997ff3dc22d2ff0718f268750 --- /dev/null +++ b/linter/test_rules/rule144.ts.autofix.skip @@ -0,0 +1,530 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 17, + "column": 1, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "autofixable": false, + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, + { + "line": 32, + "column": 12, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 56, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 57, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 58, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 58, + "column": 31, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 59, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 61, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 62, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 63, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 64, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 65, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 66, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 67, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 68, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 69, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 70, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 71, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 72, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 73, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 74, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 75, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 76, + "column": 8, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 85, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 86, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 86, + "column": 32, + "problem": "ClassAsObject", + "autofixable": false, + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 87, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 87, + "column": 32, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 88, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 90, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 91, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 92, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 93, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 94, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 104, + "column": 32, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 105, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 105, + "column": 28, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 106, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 106, + "column": 32, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 37, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 63, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 108, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 108, + "column": 37, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 109, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 109, + "column": 26, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 110, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 110, + "column": 47, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 111, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 111, + "column": 37, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 112, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 112, + "column": 26, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 113, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 113, + "column": 35, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 114, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 114, + "column": 30, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 115, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 115, + "column": 40, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 116, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 116, + "column": 26, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 117, + "column": 13, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 117, + "column": 37, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + } + ] +} diff --git a/linter/test_rules/rule144.ts.relax.json b/linter/test_rules/rule144.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..55e798673cbf641d8e6d7f0979c79cd280bcb43c --- /dev/null +++ b/linter/test_rules/rule144.ts.relax.json @@ -0,0 +1,466 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 17, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, + { + "line": 32, + "column": 12, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 56, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 57, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 58, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 58, + "column": 31, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 59, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 61, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 62, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 63, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 64, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 65, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 66, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 67, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 68, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 69, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 70, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 71, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 72, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 73, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 74, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 75, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 76, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 85, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 86, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 86, + "column": 32, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 87, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 87, + "column": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 88, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 90, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 91, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 92, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 93, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 94, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 104, + "column": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 105, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 105, + "column": 28, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 106, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 106, + "column": 32, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 63, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 108, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 108, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 109, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 109, + "column": 26, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 110, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 110, + "column": 47, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 111, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 111, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 112, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 112, + "column": 26, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 113, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 113, + "column": 35, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 114, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 114, + "column": 30, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 115, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 115, + "column": 40, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 116, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 116, + "column": 26, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 117, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 117, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + } + ] +} diff --git a/linter/test_rules/rule144.ts.strict.json b/linter/test_rules/rule144.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..55e798673cbf641d8e6d7f0979c79cd280bcb43c --- /dev/null +++ b/linter/test_rules/rule144.ts.strict.json @@ -0,0 +1,466 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 17, + "column": 1, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 31, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 32, + "column": 1, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + }, + { + "line": 32, + "column": 12, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 56, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 57, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 58, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 58, + "column": 31, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 59, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 61, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 62, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 63, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 64, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 65, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 66, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 67, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 68, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 69, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 70, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 71, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 72, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 73, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 74, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 75, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 76, + "column": 8, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 85, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 86, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 86, + "column": 32, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 87, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 87, + "column": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 88, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 90, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 91, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 92, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 93, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 94, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 104, + "column": 32, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 105, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 105, + "column": 28, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 106, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 106, + "column": 32, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 107, + "column": 63, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 108, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 108, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 109, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 109, + "column": 26, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 110, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 110, + "column": 47, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 111, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 111, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 112, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 112, + "column": 26, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 113, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 113, + "column": 35, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 114, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 114, + "column": 30, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 115, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 115, + "column": 40, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 116, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 116, + "column": 26, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 117, + "column": 13, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 117, + "column": 37, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + } + ] +} diff --git a/linter/test_rules/rule148.ts b/linter/test_rules/rule148.ts deleted file mode 100644 index 1266c40595f0a5228c263ff44836619cc5c7dff3..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule148.ts +++ /dev/null @@ -1,7 +0,0 @@ -function classDecorator(x: any, y: any): void { - // -} - -@classDecorator -class BugReport { -} \ No newline at end of file diff --git a/linter/test_rules/rule148.ts.autofix.json b/linter/test_rules/rule148.ts.autofix.json deleted file mode 100644 index ae3da58a4eb2d4764ff5cea8573eaaee607bc9a0..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule148.ts.autofix.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 28, - "problem": "AnyType", - "autofixable": false, - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 1, - "column": 36, - "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_rules/rule148.ts.relax.json b/linter/test_rules/rule148.ts.relax.json deleted file mode 100644 index fd5d1aba7d1cfeee729d072218d10fd9da3f3fbc..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule148.ts.relax.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 28, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 1, - "column": 36, - "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_rules/rule148.ts.strict.json b/linter/test_rules/rule148.ts.strict.json deleted file mode 100644 index fd5d1aba7d1cfeee729d072218d10fd9da3f3fbc..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule148.ts.strict.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 28, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 1, - "column": 36, - "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_rules/rule149.ts b/linter/test_rules/rule149.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f9511d5d083248c3cf4fd43a50c8f1a41311cf8 --- /dev/null +++ b/linter/test_rules/rule149.ts @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Something, SomethingFactory, SomethingBar, Bar, Select } from "./oh_modules/ohos_factory"; + +class C { + static a = 5 + static b = 8 +} + +namespace H { + export class G {} +} + +let c = C +c = C +let g = H.G +g = H.G + +let ca = C.a +let cb = C.b + +let cc = new C() +let gg = new H.G() + +function foo1(arg: typeof C) {} +foo1(C) + +function foo2(arg: C) { + return C +} + +function foo3(arg: typeof H.G) {} +foo3(H.G) + +function foo4(arg: H.G) { + return H.G +} + +class A {} +interface B {} +interface I {} +class CC extends A implements I, B {} + +class D { + constructor(arg: typeof C) {} +} +new D(C) + +type X = D; + +namespace test1 { + class SomethingFoo extends Something { } + namespace NS { export class SomethingFoo extends Something { } } + + let fact = SomethingFactory.getInstance(); + + let x1 = fact.create1(SomethingFoo).beep(); + let x2 = fact.create1(SomethingBar).beep(); + let x3 = fact.create1(NS.SomethingFoo).beep(); + + let x4 = fact.create2({ o: SomethingFoo }); + let x5 = fact.create2({ o: SomethingBar }); + let x6 = fact.create2({ o: NS.SomethingFoo }); + + let x7 = fact.create3(() => SomethingFoo); + let x8 = fact.create4(() => SomethingFoo); + + let x9 = new Bar(SomethingFoo); +} + +enum Color { WHITE, BLUE, RED }; +let color: Color = Color.RED; + +for (let item = 0; item < Object.keys(Color).length; item++) { + console.log(item); +} + +foo2(() => C); + +export { C as H }; + +// #14228 +let data = new Select().from(C).eq('key').query(C); // Ok +invalid_func(C); // Ok +let a: any; +a.foo(C); // Ok + +let col = 'WHITE'; +console.log(Color[col]) + +// #14184 +namespace NS { + export enum E { + A = 'A', + B = 'B', + C = 'C' + } +} + +let s: string = 'B'; +let s2: string = NS.E[s]; + +for (let item = 0; item < Object.keys(NS.E).length; item++) { + console.log(item); +} + +/** + * {@link C} - should not report error + */ +class JSDocClass {} \ No newline at end of file diff --git a/linter/test_rules/rule149.ts.autofix.skip b/linter/test_rules/rule149.ts.autofix.skip new file mode 100644 index 0000000000000000000000000000000000000000..65aa568c71c6a269fe513c0cf566d95494390365 --- /dev/null +++ b/linter/test_rules/rule149.ts.autofix.skip @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/linter/test_rules/rule149.ts.relax.json b/linter/test_rules/rule149.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..28bc1d6d877ca11120570bbba8f82ed02ce0db16 --- /dev/null +++ b/linter/test_rules/rule149.ts.relax.json @@ -0,0 +1,205 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "http://www.apache.org/licenses/LICENSE-2.0", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 27, + "column": 9, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 28, + "column": 5, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 29, + "column": 11, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 30, + "column": 7, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 38, + "column": 20, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 39, + "column": 6, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 42, + "column": 12, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 45, + "column": 20, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 46, + "column": 8, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 49, + "column": 14, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 58, + "column": 22, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 60, + "column": 7, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 68, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 70, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 71, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 72, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 74, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 75, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 76, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 78, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 79, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 81, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 87, + "column": 39, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 91, + "column": 12, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 96, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 98, + "column": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 116, + "column": 42, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule149.ts.strict.json b/linter/test_rules/rule149.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..28bc1d6d877ca11120570bbba8f82ed02ce0db16 --- /dev/null +++ b/linter/test_rules/rule149.ts.strict.json @@ -0,0 +1,205 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "http://www.apache.org/licenses/LICENSE-2.0", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 27, + "column": 9, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 28, + "column": 5, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 29, + "column": 11, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 30, + "column": 7, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 38, + "column": 20, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 39, + "column": 6, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 42, + "column": 12, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 45, + "column": 20, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 46, + "column": 8, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 49, + "column": 14, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 58, + "column": 22, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 60, + "column": 7, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 68, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 70, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 71, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 72, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 74, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 75, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 76, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 78, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 79, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 81, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 87, + "column": 39, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 91, + "column": 12, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + }, + { + "line": 96, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 98, + "column": 8, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 116, + "column": 42, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule150.ts b/linter/test_rules/rule150.ts new file mode 100644 index 0000000000000000000000000000000000000000..8669968123e2fa001e37112a1351cb75abf1b427 --- /dev/null +++ b/linter/test_rules/rule150.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import X1 from "X"; +import { X2 } from "X"; +import { X3 as X4 } from "X"; + +function f() {}; + +import X5 from "X"; +import { X6 } from "X"; +import { X7 as X8 } from "X"; diff --git a/linter/test_rules/rule150.ts.autofix.skip b/linter/test_rules/rule150.ts.autofix.skip new file mode 100644 index 0000000000000000000000000000000000000000..65aa568c71c6a269fe513c0cf566d95494390365 --- /dev/null +++ b/linter/test_rules/rule150.ts.autofix.skip @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/linter/test_rules/rule150.ts.relax.json b/linter/test_rules/rule150.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..2521bd90f39216a9db92255e91e6c2eabfc4bfe3 --- /dev/null +++ b/linter/test_rules/rule150.ts.relax.json @@ -0,0 +1,33 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 22, + "column": 1, + "problem": "ImportAfterStatement" + }, + { + "line": 23, + "column": 1, + "problem": "ImportAfterStatement" + }, + { + "line": 24, + "column": 1, + "problem": "ImportAfterStatement" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule150.ts.strict.json b/linter/test_rules/rule150.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..2521bd90f39216a9db92255e91e6c2eabfc4bfe3 --- /dev/null +++ b/linter/test_rules/rule150.ts.strict.json @@ -0,0 +1,33 @@ +{ + "copyright": [ + "Copyright (c) 2022-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 22, + "column": 1, + "problem": "ImportAfterStatement" + }, + { + "line": 23, + "column": 1, + "problem": "ImportAfterStatement" + }, + { + "line": 24, + "column": 1, + "problem": "ImportAfterStatement" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule151.ts b/linter/test_rules/rule151.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd1e530caa0989a80f1226c8b1a1d9a6c6a7c8f3 --- /dev/null +++ b/linter/test_rules/rule151.ts @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { fooOh, barOh } from './oh_modules/ohos_lib' +type ESObject = any + +class A {} + +let g1: ESObject +let g2: ESObject[] +let g3: A + +class B { + f1: ESObject + f2: ESObject[] + f3: A + + constructor(p1: ESObject, p2: ESObject[], p3: A) { + this.f1 = p1 + this.f2 = p2 + this.f3 = p3 + } + + foo1(p1: ESObject, p2: ESObject[], p3: A): ESObject { + return p1 + } + + foo2(p1: ESObject, p2: ESObject[], p3: A): ESObject[] { + return p2 + } + + foo3(p1: ESObject, p2: ESObject[], p3: A): A { + return p3 + } +} + +function bar1(p1: ESObject, p2: ESObject[], p3: A): ESObject { + return p1 +} + +function bar2(p1: ESObject, p2: ESObject[], p3: A): ESObject[] { + return p2 +} + +function bar3(p1: ESObject, p2: ESObject[], p3: A): A { + return p3 +} + +function ff(): {x: number} { + return {x: 10} +} + +function baz(p1: ESObject, p2: ESObject[], p3: A): void { + const c1: ESObject = p1; + const c2: ESObject[] = p2 + const c3: A = p3 + + let v1: ESObject = p1 + let v2: ESObject[] = p2 + let v3: A = p3 + + v1 = c1 + v2 = c2 + v3 = c3 + + v1.x = 10 + v1.foo() + v1[10] = 20 + v1(20) + + v1 = {} + v1 = "abc" + v1 = ff() + v1 = [1, 2] + v1 = [p1, c1] + v1 = [p1, c1, "abc"] + v1 = new A() + + let v11: ESObject = {} + let v12: ESObject = "abc" + let v13: ESObject = ff() + let v14: ESObject = [1, 2] + let v15: ESObject = [p1, c1] + let v16: ESObject = [p1, c1, "abc"] + let v17: ESObject = new A() + + let n1: number = v1 + n1 = v1 + let n2: number = p1 as number +} + +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 = t4[] + +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: ESObject +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 {} + +foo2({ k: 'k', h: {t: 1}}) // we can assign anything to the esobject, even untyped literal +let q1: ESObject = 1; // CTE - ``ESObject`` typed variable can only be local +let q2: ESObject = fooOh(); // CTE - ``ESObject`` typed variable can only be local +let q3: ESObject = q2; // CTE - ``ESObject`` typed variable can only be local +function f() { + let e1 = fooOh(); // CTE - type of e1 is `any` + let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values + let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values + let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values + let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values + let e6: ESObject = fooOh(); // OK - explicitly annotaded as ESObject + let e7: ESObject = e6; // OK - initialize ESObject with ESObject + e6['prop'] // CTE - can't access dynamic properties of ESObject + e6[1] // CTE - can't access dynamic properties of ESObject + e6.prop // CTE - can't access dynamic properties of ESObject + barOh(e6) // OK - ESObject is passed to interop call + e6 = e7 // OK - ESObject is assigned to ESObject +} diff --git a/linter/test_rules/rule151.ts.autofix.skip b/linter/test_rules/rule151.ts.autofix.skip new file mode 100644 index 0000000000000000000000000000000000000000..65aa568c71c6a269fe513c0cf566d95494390365 --- /dev/null +++ b/linter/test_rules/rule151.ts.autofix.skip @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/linter/test_rules/rule151.ts.relax.json b/linter/test_rules/rule151.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..5bab1a3eee7a781b35c0996be116badfe9617820 --- /dev/null +++ b/linter/test_rules/rule151.ts.relax.json @@ -0,0 +1,683 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 16, + "column": 17, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 21, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 22, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 25, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 26, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 27, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 29, + "column": 21, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 29, + "column": 35, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 29, + "column": 53, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 14, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 46, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 58, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 14, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 46, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 58, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 14, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 46, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 60, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 19, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 33, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 51, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 63, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 19, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 33, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 51, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 63, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 19, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 33, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 51, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 65, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 60, + "column": 16, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 61, + "column": 12, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 64, + "column": 18, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 64, + "column": 32, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 64, + "column": 50, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 66, + "column": 15, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 67, + "column": 17, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 70, + "column": 13, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 71, + "column": 15, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 77, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 78, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 79, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 80, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 82, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 83, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 85, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 86, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 87, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 88, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 90, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 91, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 93, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 94, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 95, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 96, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 98, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 99, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 103, + "column": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 105, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 106, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 108, + "column": 18, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 109, + "column": 18, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 114, + "column": 25, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 115, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 119, + "column": 25, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 119, + "column": 36, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 136, + "column": 25, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 136, + "column": 38, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 148, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 149, + "column": 1, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 154, + "column": 32, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 154, + "column": 45, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 154, + "column": 58, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 162, + "column": 32, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 162, + "column": 47, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 162, + "column": 60, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 170, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 172, + "column": 22, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 174, + "column": 30, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 176, + "column": 19, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 177, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 178, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 179, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 181, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 182, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 183, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 184, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 185, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 188, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 189, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 190, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule151.ts.strict.json b/linter/test_rules/rule151.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..86c0f49acf614ff7fd4b654983ee1a6684b0d3a3 --- /dev/null +++ b/linter/test_rules/rule151.ts.strict.json @@ -0,0 +1,683 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 16, + "column": 17, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 21, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 22, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 25, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 26, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 27, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 29, + "column": 21, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 29, + "column": 35, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 29, + "column": 53, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 14, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 46, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 35, + "column": 58, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 14, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 46, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 39, + "column": 58, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 14, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 46, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 43, + "column": 60, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 19, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 33, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 51, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 48, + "column": 63, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 19, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 33, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 51, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 52, + "column": 63, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 19, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 33, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 51, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 56, + "column": 65, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 60, + "column": 16, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 61, + "column": 12, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 64, + "column": 18, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 64, + "column": 32, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 64, + "column": 50, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 66, + "column": 15, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 67, + "column": 17, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 70, + "column": 13, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 71, + "column": 15, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 77, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 78, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 79, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 80, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 82, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 83, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 85, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 86, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 87, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 88, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 90, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 91, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 93, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 94, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 95, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 96, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 98, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 99, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 103, + "column": 12, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 105, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 106, + "column": 11, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 108, + "column": 18, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 109, + "column": 18, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 114, + "column": 25, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 115, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 119, + "column": 25, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 119, + "column": 36, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 136, + "column": 25, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 136, + "column": 38, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 148, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 149, + "column": 1, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 154, + "column": 32, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 154, + "column": 45, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 154, + "column": 58, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 162, + "column": 32, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 162, + "column": 47, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 162, + "column": 60, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 170, + "column": 28, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 172, + "column": 22, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 174, + "column": 30, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 176, + "column": 19, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 177, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 178, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 179, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 181, + "column": 9, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 182, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 183, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 184, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 185, + "column": 9, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 188, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 189, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + }, + { + "line": 190, + "column": 5, + "problem": "EsObjectType", + "suggest": "", + "rule": "Usage of \"ESObject\" type is restricted (arkts-limited-esobj)" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule152.ts b/linter/test_rules/rule152.ts new file mode 100644 index 0000000000000000000000000000000000000000..1a791de58986ce521cdfcf2ecb4935ecd490acf2 --- /dev/null +++ b/linter/test_rules/rule152.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class C { + Name : string = "Toto"; + getName: function(): string { + return this.Name; + } + +} + +let p: C { + Name: "Titi"; +} + +let p1: C { + Name: "Tata"; +} + +console.log(p.getName.apply(p1)); +console.log(p.getName.call(p1)); \ No newline at end of file diff --git a/linter/test_rules/rule109.ts.autofix.json b/linter/test_rules/rule152.ts.autofix.skip similarity index 44% rename from linter/test_rules/rule109.ts.autofix.json rename to linter/test_rules/rule152.ts.autofix.skip index 0b6dbe558cc7c42ae1fc9c765e9f3953417d230f..7156573971ef42382f795c0fecafbfc6aa47a818 100644 --- a/linter/test_rules/rule109.ts.autofix.json +++ b/linter/test_rules/rule152.ts.autofix.skip @@ -1,20 +1,28 @@ { "nodes": [ { - "line": 4, - "column": 5, - "problem": "IndexMember", + "line": 2, + "column": 13, + "problem": "SymbolType", "autofixable": false, "suggest": "", - "rule": "Indexed signatures are not supported (arkts-no-indexed-signatures)" + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" }, { - "line": 7, - "column": 24, + "line": 4, + "column": 9, "problem": "ObjectLiteralNoContextType", "autofixable": false, "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 5, + "column": 4, + "problem": "ComputedPropertyName", + "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/rule152.ts.relax.json b/linter/test_rules/rule152.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..ba0504709df4f1fbe271b123cc68f86608162588 --- /dev/null +++ b/linter/test_rules/rule152.ts.relax.json @@ -0,0 +1,23 @@ +{ + "nodes": [ + { + "line": 31, + "column": 23, + "problem": "FunctionApplyCall", + "rule": "\"Function.apply\", \"Function.call\" are not supported (arkts-no-func-apply-call)" + }, + { + "line": 32, + "column": 23, + "problem": "FunctionApplyCall", + "rule": "\"Function.apply\", \"Function.call\" are not supported (arkts-no-func-apply-call)" + }, + { + "line": 17, + "column": 4, + "problem": "StrictDiagnostic", + "suggest": "Property 'getName' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'getName' has no initializer and is not definitely assigned in the constructor." + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule152.ts.strict.json b/linter/test_rules/rule152.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..4710c9dfe13fd23d1995abd0138473597bbe5961 --- /dev/null +++ b/linter/test_rules/rule152.ts.strict.json @@ -0,0 +1,37 @@ +{ + "nodes": [ + { + "line": 23, + "column": 10, + "problem": "DestructuringDeclaration", + "suggest": "", + "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)" + }, + { + "line": 27, + "column": 11, + "problem": "DestructuringDeclaration", + "suggest": "", + "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)" + }, + { + "line": 31, + "column": 23, + "problem": "FunctionApplyCall", + "rule": "\"Function.apply\", \"Function.call\" are not supported (arkts-no-func-apply-call)" + }, + { + "line": 32, + "column": 23, + "problem": "FunctionApplyCall", + "rule": "\"Function.apply\", \"Function.call\" are not supported (arkts-no-func-apply-call)" + }, + { + "line": 17, + "column": 4, + "problem": "StrictDiagnostic", + "suggest": "Property 'getName' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'getName' has no initializer and is not definitely assigned in the constructor." + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule45.ts b/linter/test_rules/rule45.ts deleted file mode 100644 index 8816b00216735e698ba1f0bac994caf36f0fedd1..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule45.ts +++ /dev/null @@ -1,8 +0,0 @@ - -let f = (s /* type any is assumed */) => { - console.log(s) -} - -let foo = (s: string) => { - console.log(s) -} diff --git a/linter/test_rules/rule45.ts.autofix.json b/linter/test_rules/rule45.ts.autofix.json deleted file mode 100644 index b07ed33fd80291456ce2ab3e65de0c0eec82bee2..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule45.ts.autofix.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 10, - "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_rules/rule45.ts.relax.json b/linter/test_rules/rule45.ts.relax.json deleted file mode 100644 index af6deaf3cde344e77629e64fdf30788ff8eeeccf..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule45.ts.relax.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 10, - "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_rules/rule45.ts.strict.json b/linter/test_rules/rule45.ts.strict.json deleted file mode 100644 index af6deaf3cde344e77629e64fdf30788ff8eeeccf..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule45.ts.strict.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 2, - "column": 10, - "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_rules/rule54.tsx b/linter/test_rules/rule54.tsx new file mode 100644 index 0000000000000000000000000000000000000000..50fe6d8a9e67cdee33a6a4a3b9fa2e9ad88a5843 --- /dev/null +++ b/linter/test_rules/rule54.tsx @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React from 'react'; +export const HelloWorld = () =>

Hello world

; + +export const ATag = () => ; + +const a = ( +
+ {[10, 20].map((i: number) => {i / 2}) } +
+); \ No newline at end of file diff --git a/linter/test_rules/rule54.tsx.autofix.skip b/linter/test_rules/rule54.tsx.autofix.skip new file mode 100644 index 0000000000000000000000000000000000000000..65aa568c71c6a269fe513c0cf566d95494390365 --- /dev/null +++ b/linter/test_rules/rule54.tsx.autofix.skip @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/linter/test_rules/rule54.tsx.relax.json b/linter/test_rules/rule54.tsx.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..835896f99dad358b07d3f261febba426e9dfbfb7 --- /dev/null +++ b/linter/test_rules/rule54.tsx.relax.json @@ -0,0 +1,43 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 17, + "column": 33, + "problem": "JsxElement" + }, + { + "line": 19, + "column": 27, + "problem": "JsxElement" + }, + { + "line": 21, + "column": 7, + "problem": "AnyType" + }, + { + "line": 22, + "column": 5, + "problem": "JsxElement" + }, + { + "line": 23, + "column": 38, + "problem": "JsxElement" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule54.tsx.strict.json b/linter/test_rules/rule54.tsx.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..c8561e293d5b069110d947f1dbb6a04d43b9f4ee --- /dev/null +++ b/linter/test_rules/rule54.tsx.strict.json @@ -0,0 +1,58 @@ +{ + "copyright": [ + "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "nodes": [ + { + "line": 17, + "column": 27, + "problem": "LimitedReturnTypeInference" + }, + { + "line": 17, + "column": 33, + "problem": "JsxElement" + }, + { + "line": 19, + "column": 21, + "problem": "LimitedReturnTypeInference" + }, + { + "line": 19, + "column": 27, + "problem": "JsxElement" + }, + { + "line": 21, + "column": 7, + "problem": "AnyType" + }, + { + "line": 22, + "column": 5, + "problem": "JsxElement" + }, + { + "line": 23, + "column": 23, + "problem": "LimitedReturnTypeInference" + }, + { + "line": 23, + "column": 38, + "problem": "JsxElement" + } + ] +} \ No newline at end of file diff --git a/linter/test_rules/rule63.ts b/linter/test_rules/rule63.ts deleted file mode 100644 index 892bd7189b3643161042997f87a8414088be1e05..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule63.ts +++ /dev/null @@ -1,15 +0,0 @@ -enum E { E1, E2 } - -let a = 10 + 32 // 42 -let b = E.E1 + 10 // 10 -let c = 10 + "5" // "105" - -let d = "5" + E.E2 // "51" -let e = "Hello, " + "world!" // "Hello, world!" -let f = "string" + true // "stringtrue" - -let g = (new Object()) + "string" // "[object Object]string" - -let i = true + true // JS: 2, TS: compile-time error -let j = true + 2 // JS: 3, TS: compile-time error -let k = E.E1 + true // JS: 1, TS: compile-time error \ No newline at end of file diff --git a/linter/test_rules/rule63.ts.autofix.json b/linter/test_rules/rule63.ts.autofix.json deleted file mode 100644 index c7b928233d39252bea33c1fb165d5886b208b718..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule63.ts.autofix.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "nodes": [ - { - "line": 13, - "column": 5, - "problem": "AnyType", - "autofixable": false, - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 14, - "column": 5, - "problem": "AnyType", - "autofixable": false, - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 15, - "column": 5, - "problem": "AnyType", - "autofixable": false, - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - } - ] -} diff --git a/linter/test_rules/rule63.ts.relax.json b/linter/test_rules/rule63.ts.relax.json deleted file mode 100644 index 324172c396efb371cf19b611133ebd51c040aa0e..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule63.ts.relax.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "nodes": [ - { - "line": 13, - "column": 5, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 14, - "column": 5, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 15, - "column": 5, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - } - ] -} diff --git a/linter/test_rules/rule63.ts.strict.json b/linter/test_rules/rule63.ts.strict.json deleted file mode 100644 index 324172c396efb371cf19b611133ebd51c040aa0e..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule63.ts.strict.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "nodes": [ - { - "line": 13, - "column": 5, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 14, - "column": 5, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - }, - { - "line": 15, - "column": 5, - "problem": "AnyType", - "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" - } - ] -} diff --git a/linter/test_rules/rule76.ts b/linter/test_rules/rule76.ts deleted file mode 100644 index d0913cbd2fda4d223f3dec555eb29247f59352e7..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule76.ts +++ /dev/null @@ -1,10 +0,0 @@ -let [a, b, c] = [1, "hello", true] - -let a2 = 1 -let b2 = "hello" -let c2 = true - -let arr: Object[] = [1, "hello", true] -let a1 = arr[0] -let b1 = arr[1] -let c1 = arr[2] \ No newline at end of file diff --git a/linter/test_rules/rule76.ts.autofix.json b/linter/test_rules/rule76.ts.autofix.json deleted file mode 100644 index 84c9ce9886d6d149595a468b219222e39af37a6b..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule76.ts.autofix.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 5, - "problem": "DestructuringDeclaration", - "autofixable": false, - "suggest": "", - "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule76.ts.relax.json b/linter/test_rules/rule76.ts.relax.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule76.ts.relax.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule76.ts.strict.json b/linter/test_rules/rule76.ts.strict.json deleted file mode 100644 index 50913e605d6420f5cf315ebbbdbd23763d79ef04..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule76.ts.strict.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "nodes": [ - { - "line": 1, - "column": 5, - "problem": "DestructuringDeclaration", - "suggest": "", - "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)" - } - ] -} \ No newline at end of file diff --git a/linter/test_rules/rule82.ts b/linter/test_rules/rule82.ts deleted file mode 100644 index 597aa69cbd62031d55d60cd525a0f59d5f33120f..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule82.ts +++ /dev/null @@ -1,9 +0,0 @@ -let a: Set = new Set([1, 2, 3]) -for (let s of a) { - console.log(s) -} - -let numbers = Array.from(a.values()) -for (let n of numbers) { - console.log(n) -} \ No newline at end of file diff --git a/linter/test_rules/rule82.ts.autofix.json b/linter/test_rules/rule82.ts.autofix.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule82.ts.autofix.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule82.ts.relax.json b/linter/test_rules/rule82.ts.relax.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule82.ts.relax.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file diff --git a/linter/test_rules/rule82.ts.strict.json b/linter/test_rules/rule82.ts.strict.json deleted file mode 100644 index 13f13363f579325755e8954b4011963971667481..0000000000000000000000000000000000000000 --- a/linter/test_rules/rule82.ts.strict.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodes": [] -} \ No newline at end of file