diff --git a/linter-4.2/.gitignore b/linter-4.2/.gitignore index 4797db793b998b8c2ea246115378791d451072f7..3feb73341ba4f96fd83c2da4fba0914f5b416f10 100644 --- a/linter-4.2/.gitignore +++ b/linter-4.2/.gitignore @@ -8,4 +8,5 @@ cookbook_convertor/md .vscode .cache test/**/results +test_rules/**/results package-lock.json \ No newline at end of file diff --git a/linter-4.2/package.json b/linter-4.2/package.json index e01513b09711ccebe7f05d5bb9c026944614cb35..651fc138f3956a2c3dcb3f761dc83b75fce18deb 100644 --- a/linter-4.2/package.json +++ b/linter-4.2/package.json @@ -17,7 +17,10 @@ "build": "npm run clean && npm run compile && npm run webpack && npm run pack:linter", "postinstall": "npm run build", "pack:linter": "rimraf bundle && mkdir bundle && npm pack --pack-destination bundle", - "test": "npm run compile && rimraf test/results && node build/src/TestRunner.js test" + "test": "npm run compile && rimraf test/results test_rules/results && node build/src/TestRunner.js test test_rules", + "test_main": "npm run compile && rimraf test/results && node build/src/TestRunner.js test", + "test_rules": "npm run compile && rimraf test_rules/results && node build/src/TestRunner.js test_rules", + "update-tests": "node scripts/update-test-results.mjs test test_rules" }, "devDependencies": { "@types/node": "18.11.7", diff --git a/linter-4.2/test/update-test-results.bat b/linter-4.2/scripts/update-test-results.bat similarity index 100% rename from linter-4.2/test/update-test-results.bat rename to linter-4.2/scripts/update-test-results.bat diff --git a/linter-4.2/test/update-test-results.mjs b/linter-4.2/scripts/update-test-results.mjs similarity index 68% rename from linter-4.2/test/update-test-results.mjs rename to linter-4.2/scripts/update-test-results.mjs index b750c0706ffe4da2e5de06b349c1d716986a62d5..dc579e42453a4416215504af7d0e3133221a4f33 100644 --- a/linter-4.2/test/update-test-results.mjs +++ b/linter-4.2/scripts/update-test-results.mjs @@ -34,8 +34,17 @@ const AUTOFIX_SKIP_EXT = '.autofix.skip'; const DIFF_EXT = '.diff'; const RESULTS_DIR = 'results' +let testDirs = []; + // forces to update all tests regardless of whether there was diff in a test result -const force_update = process.argv.includes('--force'); +const force_update = false; + +for (let arg of process.argv.slice(2)) { + if (arg === '--force') + force_update = true; + else + testDirs.push(arg); +} const DEFAULT_COPYRIGHT = [ "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", @@ -61,25 +70,25 @@ function readTestFile(filePath) { } } -function updateTest(testFile, mode) { +function updateTest(testDir, testFile, mode) { let resultExt = RESULT_EXT[mode]; let testFileWithExt = testFile + resultExt; // Do not update autofix result if test is skipped - if (mode === Mode.AUTOFIX && fs.existsSync(testFile + AUTOFIX_SKIP_EXT)) { + if (mode === Mode.AUTOFIX && fs.existsSync(path.join(testDir, testFileWithExt + AUTOFIX_SKIP_EXT))) { return; } // Update test result when 'diff' exists or the 'force' option is enabled. - if (!fs.existsSync(path.join(RESULTS_DIR, testFileWithExt + DIFF_EXT)) && !force_update) { + if (!fs.existsSync(path.join(testDir, RESULTS_DIR, testFileWithExt + DIFF_EXT)) && !force_update) { return; } - let expectedResult = readTestFile(testFileWithExt); + let expectedResult = readTestFile(path.join(testDir, testFileWithExt)); const copyright = expectedResult?.copyright ?? DEFAULT_COPYRIGHT; - let actualResult = readTestFile(path.join(RESULTS_DIR, testFileWithExt)); + let actualResult = readTestFile(path.join(testDir, RESULTS_DIR, testFileWithExt)); if (!actualResult || !actualResult.nodes) { console.log(`Failed to update ${testFileWithExt}: couldn't read ACTUAL result file.`); return; @@ -87,28 +96,24 @@ function updateTest(testFile, mode) { // Write file with actual test results. let newResultJSON = JSON.stringify({ copyright, nodes: actualResult.nodes }, null, 4); - fs.writeFileSync(testFileWithExt, newResultJSON); + fs.writeFileSync(path.join(testDir, testFileWithExt), newResultJSON); console.log(`Updated ${testFileWithExt}`); } -if (!fs.existsSync(RESULTS_DIR)) { - console.log(`The ${RESULTS_DIR} dir does not exist!`); - process.exit(0); -} +for (let testDir of testDirs) { + if (!fs.existsSync(path.join(testDir, RESULTS_DIR))) continue; -// Get tests from test directory. -let testFiles = fs.readdirSync(".").filter(x => - (x.trimEnd().endsWith(TS_EXT) && !x.trimEnd().endsWith(D_TS_EXT)) || x.trimEnd().endsWith(TSX_EXT)); + // Get tests from test directory. + let testFiles = fs.readdirSync(testDir).filter(x => + (x.trimEnd().endsWith(TS_EXT) && !x.trimEnd().endsWith(D_TS_EXT)) || x.trimEnd().endsWith(TSX_EXT)); -if (!testFiles || testFiles.length == 0) { - console.log("No tests to update."); - process.exit(0); -} + if (!testFiles) continue; -// Update result for each test for Strict and Relax modes: -for (let testFile of testFiles) { - updateTest(testFile, Mode.RELAX); - updateTest(testFile, Mode.STRICT); - updateTest(testFile, Mode.AUTOFIX); + // Update result for each test for Strict and Relax modes: + for (let testFile of testFiles) { + updateTest(testDir, testFile, Mode.RELAX); + updateTest(testDir, testFile, Mode.STRICT); + updateTest(testDir, testFile, Mode.AUTOFIX); + } } \ No newline at end of file diff --git a/linter-4.2/test/update-test-results.sh b/linter-4.2/scripts/update-test-results.sh similarity index 100% rename from linter-4.2/test/update-test-results.sh rename to linter-4.2/scripts/update-test-results.sh diff --git a/linter-4.2/src/Problems.ts b/linter-4.2/src/Problems.ts index 4f9474699046fe0c63f46718d4f0751b414cff82..7cd8809dea913fdd9c2681b5c5a111d53913194e 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -83,7 +83,6 @@ faultsAttrs[FaultID.JsxElement] = {cookBookRef: '54',}; faultsAttrs[FaultID.UnaryArithmNotNumber] = {cookBookRef: '55',}; faultsAttrs[FaultID.DeleteOperator] = {cookBookRef: '59',}; faultsAttrs[FaultID.TypeQuery] = {cookBookRef: '60',}; -// remove as rule#61: FaultID.BitOpWithWrongType => {cookBookRef: '61',}; faultsAttrs[FaultID.InstanceofUnsupported] = {cookBookRef: '65',}; faultsAttrs[FaultID.InOperator] = {cookBookRef: '66',}; faultsAttrs[FaultID.DestructuringAssignment] = {migratable: true, cookBookRef: '69',}; @@ -112,7 +111,6 @@ faultsAttrs[FaultID.ConstructorFuncs] = {cookBookRef: '106',}; faultsAttrs[FaultID.EnumMemberNonConstInit] = {cookBookRef: '111',}; faultsAttrs[FaultID.EnumMerging] = {cookBookRef: '113',}; faultsAttrs[FaultID.NamespaceAsObject] = {cookBookRef: '114',}; -faultsAttrs[FaultID.ClassAsObject] = {warning: true, cookBookRef: '-1',}; faultsAttrs[FaultID.NonDeclarationInNamespace] = {cookBookRef: '116',}; faultsAttrs[FaultID.ImportFromPath] = {cookBookRef: '119',}; faultsAttrs[FaultID.TypeOnlyImport] = {migratable: true, cookBookRef: '118',}; @@ -139,7 +137,8 @@ faultsAttrs[FaultID.LimitedStdLibApi] = {cookBookRef: '144',}; faultsAttrs[FaultID.StrictDiagnostic] = {cookBookRef: '145',}; faultsAttrs[FaultID.ErrorSuppression] = {cookBookRef: '146',}; faultsAttrs[FaultID.UnsupportedDecorators] = {cookBookRef: '148',}; -faultsAttrs[FaultID.ImportAfterStatement] = {cookBookRef: '-1',}; +faultsAttrs[FaultID.ClassAsObject] = {warning: true, cookBookRef: '149',}; +faultsAttrs[FaultID.ImportAfterStatement] = {cookBookRef: '150',}; faultsAttrs[FaultID.EsObjectType] = {cookBookRef: '8'}; faultsAttrs[FaultID.EsObjectAssignment] = {cookBookRef: '8'}; faultsAttrs[FaultID.EsObjectAccess] = {cookBookRef: '8'}; diff --git a/linter-4.2/src/TestRunner.ts b/linter-4.2/src/TestRunner.ts index e065d61b6dccfe4ee3efcfdffec3187112cdc4a7..f31ce5cbfb5f28fe1923705d792611e6a181e6ff 100644 --- a/linter-4.2/src/TestRunner.ts +++ b/linter-4.2/src/TestRunner.ts @@ -52,7 +52,7 @@ const AUTOFIX_SKIP_EXT = '.autofix.skip'; const ARGS_CONFIG_EXT = '.args.json' const DIFF_EXT = '.diff'; -function runTests(baseDir: string): number { +function runTests(testDirs: string[]): number { let hasComparisonFailures = false; // Set the IDE mode manually to enable storing information @@ -60,37 +60,36 @@ function runTests(baseDir: string): number { TypeScriptLinter.ideMode = true; TypeScriptLinter.testMode = true; - // Get tests from test directory - const testDir = baseDir ?? TEST_DIR; - const testFiles: string[] = fs.readdirSync(testDir) - .filter((x) => (x.trimEnd().endsWith(ts.Extension.Ts) && !x.trimEnd().endsWith(ts.Extension.Dts)) || x.trimEnd().endsWith(ts.Extension.Tsx)); - - if (!testFiles || testFiles.length == 0) { - logger.info('No tests to run!'); - process.exit(0); - } - let passed = 0, failed = 0; - // Run each test in Strict, Autofix, and Relax mode: - for (const testFile of testFiles) { - if (runTest(testDir, testFile, Mode.STRICT)) { - failed++; - hasComparisonFailures = true; - } - else passed++; - - if (runTest(testDir, testFile, Mode.AUTOFIX)) { - failed++; - hasComparisonFailures = true; - } - else passed++; - - if (runTest(testDir, testFile, Mode.RELAX)) { - failed++; - hasComparisonFailures = true; + // Get tests from test directory + if (!testDirs?.length) testDirs = [ TEST_DIR ]; + for (const testDir of testDirs) { + let testFiles: string[] = fs.readdirSync(testDir) + .filter((x) => (x.trimEnd().endsWith(ts.Extension.Ts) && !x.trimEnd().endsWith(ts.Extension.Dts)) || x.trimEnd().endsWith(ts.Extension.Tsx)); + + logger.info(`\nProcessing "${testDir}" directory:\n`); + + // Run each test in Strict, Autofix, and Relax mode: + for (const testFile of testFiles) { + if (runTest(testDir, testFile, Mode.STRICT)) { + failed++; + hasComparisonFailures = true; + } + else passed++; + + if (runTest(testDir, testFile, Mode.AUTOFIX)) { + failed++; + hasComparisonFailures = true; + } + else passed++; + + if (runTest(testDir, testFile, Mode.RELAX)) { + failed++; + hasComparisonFailures = true; + } + else passed++; } - else passed++; } logger.info(`\nSUMMARY: ${passed + failed} total, ${passed} passed or skipped, ${failed} failed.`); @@ -241,4 +240,4 @@ ${actualNode}`; return diff; } -runTests(process.argv[2]); \ No newline at end of file +runTests(process.argv.slice(2)); \ No newline at end of file diff --git a/linter-4.2/src/Utils.ts b/linter-4.2/src/Utils.ts index 1fc3ed1abd7b6ed8c1435be18dafe5ad0036e1d9..4414b69bc1865450e5db4d061a72a8beafa00303 100644 --- a/linter-4.2/src/Utils.ts +++ b/linter-4.2/src/Utils.ts @@ -1180,15 +1180,12 @@ export class TsUtils { if (type.isUnion()) { for (let compType of type.types) { - if (this.isLibraryType(compType)) { - return true; - } - - if (!this.isStdLibraryType(compType) && !this.isIntrinsicObjectType(compType) && !this.isAnyType(compType)) { - return false; + let isDynamic = this.isDynamicType(compType); + if (isDynamic || isDynamic === undefined) { + return isDynamic; } } - return undefined; + return false; } if (this.isLibraryType(type)) { diff --git a/linter-4.2/test/dynamic_lib.d.ts b/linter-4.2/test/dynamic_lib.d.ts index a9bb5c9a5de8a601b94c6468ce153b5eb8bbe6f9..b6a9493cb21c6446a5d06685e6fc3d87a0d9985c 100644 --- a/linter-4.2/test/dynamic_lib.d.ts +++ b/linter-4.2/test/dynamic_lib.d.ts @@ -48,3 +48,24 @@ export let dynamic_array: Array; export declare class C1 {} export declare function f2(c: C1): void; + +export type Length = string | number | Resource; +export interface Resource { + readonly id: number; + readonly type: number; +} +export type Padding = { + top?: Length; + right?: Length; + bottom?: Length; + left?: Length; +} +export type Margin = Padding; +export interface Position { + x?: Length; + y?: Length; +} + +export function padding(value: Padding | Length): any; +export function margin(value: Margin | Length): any; +export function position(value: Position): any; \ No newline at end of file diff --git a/linter-4.2/test/dynamic_object_literals.ts b/linter-4.2/test/dynamic_object_literals.ts index 7ed1e34799ca674b19c7a67ef566afdf2bb948c1..ea7f9759a2e8cf76d1eb0dd81536959bfcf1beeb 100644 --- a/linter-4.2/test/dynamic_object_literals.ts +++ b/linter-4.2/test/dynamic_object_literals.ts @@ -13,7 +13,19 @@ * limitations under the License. */ -import { I, foo, I2, I3, bar, C, getDynamicObject, dynamic_array } from "./dynamic_lib" +import { + I, + foo, + I2, + I3, + bar, + C, + getDynamicObject, + dynamic_array, + padding, + margin, + position +} from "./dynamic_lib" function main(): void { let obj: I = { @@ -67,4 +79,9 @@ function createInitProps(c: C) { } // #13483 - pass object literal to method call of exported variable -dynamic_array.splice(2, 0, {a: 1, b: '2'}); \ No newline at end of file +dynamic_array.splice(2, 0, {a: 1, b: '2'}); + +// #13550 - allow literals as property names in dynamic context +padding({'top': '0px', 'right': '5px', 'bottom': '10px', 'left': '15px'}); +margin({'top': '10px', 'right': '20px', 'bottom': '30px', 'left': '40px'}); +position({'x': '20', 'y': '40'}); \ No newline at end of file diff --git a/linter-4.2/test_rules/rule1.ts b/linter-4.2/test_rules/rule1.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0332f6435e764e006ec357ac106077999a5b8f6 --- /dev/null +++ b/linter-4.2/test_rules/rule1.ts @@ -0,0 +1,14 @@ + +var x = {"name": 1, 2: 3} + +console.log(x["name"]) +console.log(x[2]) + +class X { + public name: number = 0 +} +let y = {name: 1} +console.log(x.name) + +let z = [1, 2, 3] +console.log(y[2]) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule1.ts.autofix.json b/linter-4.2/test_rules/rule1.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..32a60bb65fcb0cb40bb1b2c2b5f7a80779c2f0cf --- /dev/null +++ b/linter-4.2/test_rules/rule1.ts.autofix.json @@ -0,0 +1,82 @@ +{ + "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": 2, + "column": 1, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 2, + "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": 2, + "column": 10, + "problem": "LiteralAsPropertyName", + "autofixable": true, + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" + }, + { + "line": 2, + "column": 21, + "problem": "LiteralAsPropertyName", + "autofixable": true, + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" + }, + { + "line": 4, + "column": 13, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 5, + "column": 13, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 10, + "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": 14, + "column": 13, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule1.ts.relax.json b/linter-4.2/test_rules/rule1.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..861e06d092491f53b401c5fa2a633ce8e932a417 --- /dev/null +++ b/linter-4.2/test_rules/rule1.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 9, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 10, + "column": 9, + "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-4.2/test_rules/rule1.ts.strict.json b/linter-4.2/test_rules/rule1.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..5728ad6cdb5502758ccbdee12f51fe5023b9ef89 --- /dev/null +++ b/linter-4.2/test_rules/rule1.ts.strict.json @@ -0,0 +1,60 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 2, + "column": 9, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 2, + "column": 10, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" + }, + { + "line": 2, + "column": 21, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" + }, + { + "line": 4, + "column": 13, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 5, + "column": 13, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 10, + "column": 9, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 14, + "column": 13, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule102.ts b/linter-4.2/test_rules/rule102.ts new file mode 100644 index 0000000000000000000000000000000000000000..adf6f4ed1d0be012d23d563bcbf840edb15ba8f1 --- /dev/null +++ b/linter-4.2/test_rules/rule102.ts @@ -0,0 +1,76 @@ +interface Mover { + getStatus(): { speed: number } +} +interface Shaker { + getStatus(): { frequency: number } +} + +interface MoverShaker extends Mover, Shaker { + getStatus(): { + speed: number + frequency: number + } +} + +class C implements MoverShaker { + private speed: number = 0 + private frequency: number = 0 + + getStatus() { + return { speed: this.speed, frequency: this.frequency } + } +} + +class MoveStatus { + public speed : number + constructor() { + this.speed = 0 + } +} +interface Mover { + getMoveStatus(): MoveStatus +} + +class ShakeStatus { + public frequency : number + constructor() { + this.frequency = 0 + } +} +interface Shaker { + getShakeStatus(): ShakeStatus +} + +class MoveAndShakeStatus { + public speed : number + public frequency : number + constructor() { + this.speed = 0 + this.frequency = 0 + } +} + +class D implements Mover, Shaker { + private move_status : MoveStatus + private shake_status : ShakeStatus + + constructor() { + this.move_status = new MoveStatus() + this.shake_status = new ShakeStatus() + } + + public getMoveStatus() : MoveStatus { + return this.move_status + } + + public getShakeStatus() : ShakeStatus { + return this.shake_status + } + + public getStatus(): MoveAndShakeStatus { + return { + speed: this.move_status.speed, + frequency: this.shake_status.frequency + } + } +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule102.ts.autofix.json b/linter-4.2/test_rules/rule102.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..e9faca40d719a7792d52ff3cecb0c70eb6f8116c --- /dev/null +++ b/linter-4.2/test_rules/rule102.ts.autofix.json @@ -0,0 +1,90 @@ +{ + "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": 1, + "column": 1, + "problem": "InterfaceMerging", + "autofixable": false, + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 2, + "column": 18, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 4, + "column": 1, + "problem": "InterfaceMerging", + "autofixable": false, + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 5, + "column": 18, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 8, + "column": 1, + "problem": "IntefaceExtendDifProps", + "autofixable": false, + "suggest": "", + "rule": "Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)" + }, + { + "line": 9, + "column": 18, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 20, + "column": 16, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 30, + "column": 1, + "problem": "InterfaceMerging", + "autofixable": false, + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 40, + "column": 1, + "problem": "InterfaceMerging", + "autofixable": false, + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule102.ts.relax.json b/linter-4.2/test_rules/rule102.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..40159bc31eeb5e29cfdcab94c0b474731110546c --- /dev/null +++ b/linter-4.2/test_rules/rule102.ts.relax.json @@ -0,0 +1,81 @@ +{ + "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": 1, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 2, + "column": 18, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 4, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 5, + "column": 18, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 8, + "column": 1, + "problem": "IntefaceExtendDifProps", + "suggest": "", + "rule": "Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)" + }, + { + "line": 9, + "column": 18, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 20, + "column": 16, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 30, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 40, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule102.ts.strict.json b/linter-4.2/test_rules/rule102.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..40159bc31eeb5e29cfdcab94c0b474731110546c --- /dev/null +++ b/linter-4.2/test_rules/rule102.ts.strict.json @@ -0,0 +1,81 @@ +{ + "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": 1, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 2, + "column": 18, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 4, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 5, + "column": 18, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 8, + "column": 1, + "problem": "IntefaceExtendDifProps", + "suggest": "", + "rule": "Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)" + }, + { + "line": 9, + "column": 18, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 20, + "column": 16, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 30, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 40, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule103.ts b/linter-4.2/test_rules/rule103.ts new file mode 100644 index 0000000000000000000000000000000000000000..19124189af7c803e2331d7a6f3f99eb0d7fbadf4 --- /dev/null +++ b/linter-4.2/test_rules/rule103.ts @@ -0,0 +1,13 @@ +interface Document { + createElement(tagName: any): Element +} + +interface Document { + createElement(tagName: string): HTMLElement +} + +interface Document { + createElement(tagName: number): HTMLDivElement + createElement(tagName: boolean): HTMLSpanElement + createElement(tagName: string, value: number): HTMLCanvasElement +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule103.ts.autofix.json b/linter-4.2/test_rules/rule103.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..0b80e8ace95cd0133057e4dfd14154cf74cd98bb --- /dev/null +++ b/linter-4.2/test_rules/rule103.ts.autofix.json @@ -0,0 +1,74 @@ +{ + "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": 1, + "column": 1, + "problem": "InterfaceMerging", + "autofixable": false, + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 1, + "column": 1, + "problem": "DeclWithDuplicateName", + "autofixable": false, + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + }, + { + "line": 2, + "column": 28, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 1, + "problem": "InterfaceMerging", + "autofixable": false, + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 5, + "column": 1, + "problem": "DeclWithDuplicateName", + "autofixable": false, + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + }, + { + "line": 9, + "column": 1, + "problem": "InterfaceMerging", + "autofixable": false, + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 9, + "column": 1, + "problem": "DeclWithDuplicateName", + "autofixable": false, + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule103.ts.relax.json b/linter-4.2/test_rules/rule103.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..cf7d4c009c5608325e39fb84113c1a58e74722e3 --- /dev/null +++ b/linter-4.2/test_rules/rule103.ts.relax.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 2, + "column": 28, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 9, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule103.ts.strict.json b/linter-4.2/test_rules/rule103.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..ed74f56a2af3396ac4bf837d4902413f1510e660 --- /dev/null +++ b/linter-4.2/test_rules/rule103.ts.strict.json @@ -0,0 +1,67 @@ +{ + "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": 1, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 1, + "column": 1, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + }, + { + "line": 2, + "column": 28, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 5, + "column": 1, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + }, + { + "line": 9, + "column": 1, + "problem": "InterfaceMerging", + "suggest": "", + "rule": "Declaration merging is not supported (arkts-no-decl-merging)" + }, + { + "line": 9, + "column": 1, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule104.ts b/linter-4.2/test_rules/rule104.ts new file mode 100644 index 0000000000000000000000000000000000000000..65df1e4e24cea4e245c04e2d15c986a828bed9f2 --- /dev/null +++ b/linter-4.2/test_rules/rule104.ts @@ -0,0 +1,7 @@ +class Control { + state: number = 0 +} + +interface SelectableControl extends Control { + select(): void +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule104.ts.autofix.json b/linter-4.2/test_rules/rule104.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..72f785ae1c63df2792bb4966433c96cb31cf53f3 --- /dev/null +++ b/linter-4.2/test_rules/rule104.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 5, + "column": 1, + "problem": "InterfaceExtendsClass", + "autofixable": false, + "suggest": "", + "rule": "Interfaces cannot extend classes (arkts-extends-only-class)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule104.ts.relax.json b/linter-4.2/test_rules/rule104.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..7b41949d17e9f435905d2ae3946dd7ec32836f1f --- /dev/null +++ b/linter-4.2/test_rules/rule104.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 1, + "problem": "InterfaceExtendsClass", + "suggest": "", + "rule": "Interfaces cannot extend classes (arkts-extends-only-class)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule104.ts.strict.json b/linter-4.2/test_rules/rule104.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..7b41949d17e9f435905d2ae3946dd7ec32836f1f --- /dev/null +++ b/linter-4.2/test_rules/rule104.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 1, + "problem": "InterfaceExtendsClass", + "suggest": "", + "rule": "Interfaces cannot extend classes (arkts-extends-only-class)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule105.ts b/linter-4.2/test_rules/rule105.ts new file mode 100644 index 0000000000000000000000000000000000000000..6bb74d05e22d625d58f5a424cdfc9c576420f5ed --- /dev/null +++ b/linter-4.2/test_rules/rule105.ts @@ -0,0 +1,15 @@ +class A { + foo() {} + bar() {} +} + +function getSomeObject() { + return new A() +} + +let obj: any = getSomeObject() +if (obj && obj.foo && obj.bar) { + console.log("Yes") // prints "Yes" in this example +} else { + console.log("No") +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule105.ts.autofix.json b/linter-4.2/test_rules/rule105.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..dec758fffc4d229b5d3fcf08f3a5c3263c9f3a56 --- /dev/null +++ b/linter-4.2/test_rules/rule105.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 12, + "problem": "PropertyRuntimeCheck", + "autofixable": false, + "suggest": "", + "rule": "Property-based runtime type checks are not supported (arkts-no-prop-existence-check)" + }, + { + "line": 11, + "column": 23, + "problem": "PropertyRuntimeCheck", + "autofixable": false, + "suggest": "", + "rule": "Property-based runtime type checks are not supported (arkts-no-prop-existence-check)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule105.ts.relax.json b/linter-4.2/test_rules/rule105.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..ea58d6f20296783ee11b6b0f7608aaa6510a8125 --- /dev/null +++ b/linter-4.2/test_rules/rule105.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 12, + "problem": "PropertyRuntimeCheck", + "suggest": "", + "rule": "Property-based runtime type checks are not supported (arkts-no-prop-existence-check)" + }, + { + "line": 11, + "column": 23, + "problem": "PropertyRuntimeCheck", + "suggest": "", + "rule": "Property-based runtime type checks are not supported (arkts-no-prop-existence-check)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule105.ts.strict.json b/linter-4.2/test_rules/rule105.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..ea58d6f20296783ee11b6b0f7608aaa6510a8125 --- /dev/null +++ b/linter-4.2/test_rules/rule105.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 10, + "column": 10, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 12, + "problem": "PropertyRuntimeCheck", + "suggest": "", + "rule": "Property-based runtime type checks are not supported (arkts-no-prop-existence-check)" + }, + { + "line": 11, + "column": 23, + "problem": "PropertyRuntimeCheck", + "suggest": "", + "rule": "Property-based runtime type checks are not supported (arkts-no-prop-existence-check)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule106.ts b/linter-4.2/test_rules/rule106.ts new file mode 100644 index 0000000000000000000000000000000000000000..1ab230279e1ed0363679b05620af70db1bf14f5c --- /dev/null +++ b/linter-4.2/test_rules/rule106.ts @@ -0,0 +1,14 @@ +class Person { + constructor( + name: string, + age: number + ) {} +} +type PersonCtor = new (name: string, age: number) => Person + +function createPerson(Ctor: PersonCtor, name: string, age: number): Person +{ + return new Ctor(name, age) +} + +const person = createPerson(Person, 'John', 30) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule106.ts.autofix.json b/linter-4.2/test_rules/rule106.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c9ee8bc8e4e80e31f467dc3fe97f4e19f860f435 --- /dev/null +++ b/linter-4.2/test_rules/rule106.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "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": 7, + "column": 19, + "problem": "ConstructorFuncs", + "autofixable": false, + "suggest": "", + "rule": "Constructor function type is not supported (arkts-no-ctor-signatures-funcs)" + }, + { + "line": 14, + "column": 29, + "problem": "ClassAsObject", + "autofixable": false, + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule106.ts.relax.json b/linter-4.2/test_rules/rule106.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..9af8cdfaaa39ec4cb6fe53f12172134a15d40320 --- /dev/null +++ b/linter-4.2/test_rules/rule106.ts.relax.json @@ -0,0 +1,32 @@ +{ + "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": 7, + "column": 19, + "problem": "ConstructorFuncs", + "suggest": "", + "rule": "Constructor function type is not supported (arkts-no-ctor-signatures-funcs)" + }, + { + "line": 14, + "column": 29, + "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-4.2/test_rules/rule106.ts.strict.json b/linter-4.2/test_rules/rule106.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..9af8cdfaaa39ec4cb6fe53f12172134a15d40320 --- /dev/null +++ b/linter-4.2/test_rules/rule106.ts.strict.json @@ -0,0 +1,32 @@ +{ + "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": 7, + "column": 19, + "problem": "ConstructorFuncs", + "suggest": "", + "rule": "Constructor function type is not supported (arkts-no-ctor-signatures-funcs)" + }, + { + "line": 14, + "column": 29, + "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-4.2/test_rules/rule109.ts b/linter-4.2/test_rules/rule109.ts new file mode 100644 index 0000000000000000000000000000000000000000..f059bcfd6f2fab0016796269283d2dec96485f3d --- /dev/null +++ b/linter-4.2/test_rules/rule109.ts @@ -0,0 +1,12 @@ +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-4.2/test_rules/rule109.ts.autofix.json b/linter-4.2/test_rules/rule109.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..0b6dbe558cc7c42ae1fc9c765e9f3953417d230f --- /dev/null +++ b/linter-4.2/test_rules/rule109.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 4, + "column": 5, + "problem": "IndexMember", + "autofixable": false, + "suggest": "", + "rule": "Indexed signatures are not supported (arkts-no-indexed-signatures)" + }, + { + "line": 7, + "column": 24, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "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-4.2/test_rules/rule109.ts.relax.json b/linter-4.2/test_rules/rule109.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..4e3cec02be669841d7f114cdc0e323a5dda3afa4 --- /dev/null +++ b/linter-4.2/test_rules/rule109.ts.relax.json @@ -0,0 +1,18 @@ +{ + "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-4.2/test_rules/rule109.ts.strict.json b/linter-4.2/test_rules/rule109.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..4e3cec02be669841d7f114cdc0e323a5dda3afa4 --- /dev/null +++ b/linter-4.2/test_rules/rule109.ts.strict.json @@ -0,0 +1,18 @@ +{ + "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-4.2/test_rules/rule111.ts b/linter-4.2/test_rules/rule111.ts new file mode 100644 index 0000000000000000000000000000000000000000..03f37395dd89b4014693d6b6072b7c866b41f6f4 --- /dev/null +++ b/linter-4.2/test_rules/rule111.ts @@ -0,0 +1,14 @@ +enum E1 { + A = 0xa, + B = 0xb, + C = Math.random(), + D = 0xd, + E // 0xe inferred +} + +enum E2 { + A = 0xa, + B = "0xb", + C = 0xc, + D = "0xd" +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule111.ts.autofix.json b/linter-4.2/test_rules/rule111.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..ac59273420b000d9ef8e218f0d8e4f124428ae0a --- /dev/null +++ b/linter-4.2/test_rules/rule111.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 4, + "column": 5, + "problem": "EnumMemberNonConstInit", + "autofixable": false, + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + }, + { + "line": 11, + "column": 5, + "problem": "EnumMemberNonConstInit", + "autofixable": false, + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + }, + { + "line": 13, + "column": 5, + "problem": "EnumMemberNonConstInit", + "autofixable": false, + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule111.ts.relax.json b/linter-4.2/test_rules/rule111.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..38d9912896ffd61392b1f3c16365a1002b0828c4 --- /dev/null +++ b/linter-4.2/test_rules/rule111.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 4, + "column": 5, + "problem": "EnumMemberNonConstInit", + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + }, + { + "line": 11, + "column": 5, + "problem": "EnumMemberNonConstInit", + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + }, + { + "line": 13, + "column": 5, + "problem": "EnumMemberNonConstInit", + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule111.ts.strict.json b/linter-4.2/test_rules/rule111.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..38d9912896ffd61392b1f3c16365a1002b0828c4 --- /dev/null +++ b/linter-4.2/test_rules/rule111.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 4, + "column": 5, + "problem": "EnumMemberNonConstInit", + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + }, + { + "line": 11, + "column": 5, + "problem": "EnumMemberNonConstInit", + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + }, + { + "line": 13, + "column": 5, + "problem": "EnumMemberNonConstInit", + "suggest": "", + "rule": "Enumeration members can be initialized only with compile time expressions of the same type (arkts-no-enum-mixed-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule113.ts b/linter-4.2/test_rules/rule113.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6880ec8701a0bd3e284c2cc77ad80c8ed84622a --- /dev/null +++ b/linter-4.2/test_rules/rule113.ts @@ -0,0 +1,11 @@ +enum Color { + RED, + GREEN +} +enum Color { + YELLOW = 2 +} +enum Color { + BLACK = 3, + BLUE +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule113.ts.autofix.json b/linter-4.2/test_rules/rule113.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..58f9d799d81d89130b4184f23d230679987e4028 --- /dev/null +++ b/linter-4.2/test_rules/rule113.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "EnumMerging", + "autofixable": false, + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + }, + { + "line": 5, + "column": 1, + "problem": "EnumMerging", + "autofixable": false, + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + }, + { + "line": 8, + "column": 1, + "problem": "EnumMerging", + "autofixable": false, + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule113.ts.relax.json b/linter-4.2/test_rules/rule113.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..b6613b8555c2881ae9177861074c9334d1da69e8 --- /dev/null +++ b/linter-4.2/test_rules/rule113.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "EnumMerging", + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + }, + { + "line": 5, + "column": 1, + "problem": "EnumMerging", + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + }, + { + "line": 8, + "column": 1, + "problem": "EnumMerging", + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule113.ts.strict.json b/linter-4.2/test_rules/rule113.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..b6613b8555c2881ae9177861074c9334d1da69e8 --- /dev/null +++ b/linter-4.2/test_rules/rule113.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "EnumMerging", + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + }, + { + "line": 5, + "column": 1, + "problem": "EnumMerging", + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + }, + { + "line": 8, + "column": 1, + "problem": "EnumMerging", + "suggest": "", + "rule": "\"enum\" declaration merging is not supported (arkts-no-enum-merging)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule114.ts b/linter-4.2/test_rules/rule114.ts new file mode 100644 index 0000000000000000000000000000000000000000..874568372cf20ee7548de48101c8833a57c1aaec --- /dev/null +++ b/linter-4.2/test_rules/rule114.ts @@ -0,0 +1,6 @@ +namespace MyNamespace { + export let x: number +} + +let m = MyNamespace +m.x = 2 \ No newline at end of file diff --git a/linter-4.2/test_rules/rule114.ts.autofix.json b/linter-4.2/test_rules/rule114.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c13bc7ded515e29229cc0fb252597ef17bfe88e3 --- /dev/null +++ b/linter-4.2/test_rules/rule114.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 5, + "column": 9, + "problem": "NamespaceAsObject", + "autofixable": false, + "suggest": "", + "rule": "Namespaces cannot be used as objects (arkts-no-ns-as-obj)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule114.ts.relax.json b/linter-4.2/test_rules/rule114.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..1e0d3c333d0c20b8ec71a0dd70f376901d61299f --- /dev/null +++ b/linter-4.2/test_rules/rule114.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 9, + "problem": "NamespaceAsObject", + "suggest": "", + "rule": "Namespaces cannot be used as objects (arkts-no-ns-as-obj)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule114.ts.strict.json b/linter-4.2/test_rules/rule114.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..1e0d3c333d0c20b8ec71a0dd70f376901d61299f --- /dev/null +++ b/linter-4.2/test_rules/rule114.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 9, + "problem": "NamespaceAsObject", + "suggest": "", + "rule": "Namespaces cannot be used as objects (arkts-no-ns-as-obj)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule116.ts b/linter-4.2/test_rules/rule116.ts new file mode 100644 index 0000000000000000000000000000000000000000..be59f4075eb2cfc106f12c48246b8b2ebfac967b --- /dev/null +++ b/linter-4.2/test_rules/rule116.ts @@ -0,0 +1,4 @@ +namespace A { + export let x: number + x = 1 +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule116.ts.autofix.json b/linter-4.2/test_rules/rule116.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..8449964f6b0aebed7a3a412a87e959afbcb33487 --- /dev/null +++ b/linter-4.2/test_rules/rule116.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 3, + "column": 5, + "problem": "NonDeclarationInNamespace", + "autofixable": false, + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule116.ts.relax.json b/linter-4.2/test_rules/rule116.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..a5030d64e8a3e5c962cfc25bcfc7d49e88e73a86 --- /dev/null +++ b/linter-4.2/test_rules/rule116.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 3, + "column": 5, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule116.ts.strict.json b/linter-4.2/test_rules/rule116.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..a5030d64e8a3e5c962cfc25bcfc7d49e88e73a86 --- /dev/null +++ b/linter-4.2/test_rules/rule116.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 3, + "column": 5, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule118.ts b/linter-4.2/test_rules/rule118.ts new file mode 100644 index 0000000000000000000000000000000000000000..d8fcc327ce966c558cead70ce89f70cea8e04fef --- /dev/null +++ b/linter-4.2/test_rules/rule118.ts @@ -0,0 +1,5 @@ + // 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-4.2/test_rules/rule118.ts.autofix.json b/linter-4.2/test_rules/rule118.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..3ff68f6c73f0870b0af431b06348497a9bf6a784 --- /dev/null +++ b/linter-4.2/test_rules/rule118.ts.autofix.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "line": 5, + "column": 12, + "problem": "TypeOnlyImport", + "autofixable": true, + "autofix": [ + { + "start": 120, + "end": 144, + "replacementText": "{ APIResponseType }" + } + ], + "suggest": "", + "rule": "Special import type declarations are not supported (arkts-no-special-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule118.ts.relax.json b/linter-4.2/test_rules/rule118.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule118.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule118.ts.strict.json b/linter-4.2/test_rules/rule118.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..d30836a74acd706fd8fe37f455f2cb38b9d30f96 --- /dev/null +++ b/linter-4.2/test_rules/rule118.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 12, + "problem": "TypeOnlyImport", + "suggest": "", + "rule": "Special import type declarations are not supported (arkts-no-special-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule119.ts b/linter-4.2/test_rules/rule119.ts new file mode 100644 index 0000000000000000000000000000000000000000..6a34b0cab0d6ca7e16fa78e951a4ed86e4661a61 --- /dev/null +++ b/linter-4.2/test_rules/rule119.ts @@ -0,0 +1,9 @@ + + // === module at "path/to/module.ts" + export const EXAMPLE_VALUE = 42 + + // Set a global variable + window.MY_GLOBAL_VAR = "Hello, world!" + + // ==== using this module: + import "path/to/module" \ No newline at end of file diff --git a/linter-4.2/test_rules/rule119.ts.autofix.json b/linter-4.2/test_rules/rule119.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..a59a65d922215e44fed98ad9076e588e8ac3819f --- /dev/null +++ b/linter-4.2/test_rules/rule119.ts.autofix.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "line": 9, + "column": 5, + "problem": "ImportAfterStatement", + "autofixable": false, + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 9, + "column": 5, + "problem": "ImportFromPath", + "autofixable": false, + "suggest": "", + "rule": "Importing a module for side-effects only is not supported (arkts-no-side-effects-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule119.ts.relax.json b/linter-4.2/test_rules/rule119.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..a4d73e61191c45fd5813b88a917d67c6c20ca366 --- /dev/null +++ b/linter-4.2/test_rules/rule119.ts.relax.json @@ -0,0 +1,17 @@ +{ + "nodes": [ + { + "line": 9, + "column": 5, + "problem": "ImportAfterStatement", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 9, + "column": 5, + "problem": "ImportFromPath", + "suggest": "", + "rule": "Importing a module for side-effects only is not supported (arkts-no-side-effects-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule119.ts.strict.json b/linter-4.2/test_rules/rule119.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..a4d73e61191c45fd5813b88a917d67c6c20ca366 --- /dev/null +++ b/linter-4.2/test_rules/rule119.ts.strict.json @@ -0,0 +1,17 @@ +{ + "nodes": [ + { + "line": 9, + "column": 5, + "problem": "ImportAfterStatement", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 9, + "column": 5, + "problem": "ImportFromPath", + "suggest": "", + "rule": "Importing a module for side-effects only is not supported (arkts-no-side-effects-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule120.ts b/linter-4.2/test_rules/rule120.ts new file mode 100644 index 0000000000000000000000000000000000000000..708e6e63e3a8339505e094f4d161066dbfe2122d --- /dev/null +++ b/linter-4.2/test_rules/rule120.ts @@ -0,0 +1 @@ +import { default as d } from "mod" \ No newline at end of file diff --git a/linter-4.2/test_rules/rule120.ts.autofix.json b/linter-4.2/test_rules/rule120.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..1b75d551f69d990bdc7c3c22ddd23185e7c50cb5 --- /dev/null +++ b/linter-4.2/test_rules/rule120.ts.autofix.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "line": 1, + "column": 10, + "problem": "DefaultImport", + "autofixable": true, + "autofix": [ + { + "start": 7, + "end": 23, + "replacementText": "d" + } + ], + "suggest": "", + "rule": "\"import default as ...\" is not supported (arkts-no-import-default-as)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule120.ts.relax.json b/linter-4.2/test_rules/rule120.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule120.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule120.ts.strict.json b/linter-4.2/test_rules/rule120.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..4f5b8f36913d90b3af05501ec9f40a2e7db9cef1 --- /dev/null +++ b/linter-4.2/test_rules/rule120.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 10, + "problem": "DefaultImport", + "suggest": "", + "rule": "\"import default as ...\" is not supported (arkts-no-import-default-as)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule121.ts b/linter-4.2/test_rules/rule121.ts new file mode 100644 index 0000000000000000000000000000000000000000..809e4434331e857c26dc49e6901e04e13e4e7d32 --- /dev/null +++ b/linter-4.2/test_rules/rule121.ts @@ -0,0 +1 @@ +import m = require("mod") \ No newline at end of file diff --git a/linter-4.2/test_rules/rule121.ts.autofix.json b/linter-4.2/test_rules/rule121.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..197c2ea1b22cba65d5a39cf28c165e8cce473e50 --- /dev/null +++ b/linter-4.2/test_rules/rule121.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ImportAssignment", + "autofixable": false, + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule121.ts.relax.json b/linter-4.2/test_rules/rule121.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..03cee4fb6fddc54fb6a6d316ad5c48b96d4f5a7e --- /dev/null +++ b/linter-4.2/test_rules/rule121.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ImportAssignment", + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule121.ts.strict.json b/linter-4.2/test_rules/rule121.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..03cee4fb6fddc54fb6a6d316ad5c48b96d4f5a7e --- /dev/null +++ b/linter-4.2/test_rules/rule121.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ImportAssignment", + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule125.ts b/linter-4.2/test_rules/rule125.ts new file mode 100644 index 0000000000000000000000000000000000000000..094f9e773c733ae315c3afe5a8eb0bc921f11b79 --- /dev/null +++ b/linter-4.2/test_rules/rule125.ts @@ -0,0 +1,13 @@ + // module1 + export class Class1 { + // ... + } + export class Class2 { + // ... + } + + // module2 + export * as utilities from "module1" + + // consumer module + import { utilities } from "module2" \ No newline at end of file diff --git a/linter-4.2/test_rules/rule125.ts.autofix.json b/linter-4.2/test_rules/rule125.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..b5ef603190f36b508aaebb3155fca086f5704d6f --- /dev/null +++ b/linter-4.2/test_rules/rule125.ts.autofix.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "line": 10, + "column": 5, + "problem": "LimitedReExporting", + "autofixable": false, + "suggest": "", + "rule": "Re-exporting is supported with restrictions (arkts-limited-reexport)" + }, + { + "line": 13, + "column": 5, + "problem": "ImportAfterStatement", + "autofixable": false, + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule125.ts.relax.json b/linter-4.2/test_rules/rule125.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..0a9e3e3bf4ca45c8aff61d0ff1911d79810227c5 --- /dev/null +++ b/linter-4.2/test_rules/rule125.ts.relax.json @@ -0,0 +1,17 @@ +{ + "nodes": [ + { + "line": 10, + "column": 5, + "problem": "LimitedReExporting", + "suggest": "", + "rule": "Re-exporting is supported with restrictions (arkts-limited-reexport)" + }, + { + "line": 13, + "column": 5, + "problem": "ImportAfterStatement", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule125.ts.strict.json b/linter-4.2/test_rules/rule125.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..0a9e3e3bf4ca45c8aff61d0ff1911d79810227c5 --- /dev/null +++ b/linter-4.2/test_rules/rule125.ts.strict.json @@ -0,0 +1,17 @@ +{ + "nodes": [ + { + "line": 10, + "column": 5, + "problem": "LimitedReExporting", + "suggest": "", + "rule": "Re-exporting is supported with restrictions (arkts-limited-reexport)" + }, + { + "line": 13, + "column": 5, + "problem": "ImportAfterStatement", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule126.ts b/linter-4.2/test_rules/rule126.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ded9440ad9e26a0c47adb233c22cb13091aed5b --- /dev/null +++ b/linter-4.2/test_rules/rule126.ts @@ -0,0 +1,12 @@ + // module1 + export = Point + + class Point { + constructor(x: number, y: number) {} + static origin = new Point(0, 0) + } + + // module2 + import Pt = require("module1") + + let p = Pt.origin diff --git a/linter-4.2/test_rules/rule126.ts.autofix.json b/linter-4.2/test_rules/rule126.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..8e115e122d108845b2bb08f1c5646e833089a8c7 --- /dev/null +++ b/linter-4.2/test_rules/rule126.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "ExportAssignment", + "autofixable": false, + "suggest": "", + "rule": "\"export = ...\" assignment is not supported (arkts-no-export-assignment)" + }, + { + "line": 10, + "column": 5, + "problem": "ImportAssignment", + "autofixable": false, + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)" + }, + { + "line": 12, + "column": 9, + "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-4.2/test_rules/rule126.ts.relax.json b/linter-4.2/test_rules/rule126.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..161b8ec8e28788bcb240ff18a149d3ac54671920 --- /dev/null +++ b/linter-4.2/test_rules/rule126.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "ExportAssignment", + "suggest": "", + "rule": "\"export = ...\" assignment is not supported (arkts-no-export-assignment)" + }, + { + "line": 10, + "column": 5, + "problem": "ImportAssignment", + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)" + }, + { + "line": 12, + "column": 9, + "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-4.2/test_rules/rule126.ts.strict.json b/linter-4.2/test_rules/rule126.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..161b8ec8e28788bcb240ff18a149d3ac54671920 --- /dev/null +++ b/linter-4.2/test_rules/rule126.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "ExportAssignment", + "suggest": "", + "rule": "\"export = ...\" assignment is not supported (arkts-no-export-assignment)" + }, + { + "line": 10, + "column": 5, + "problem": "ImportAssignment", + "suggest": "", + "rule": "\"require\" and \"import\" assignment are not supported (arkts-no-require)" + }, + { + "line": 12, + "column": 9, + "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-4.2/test_rules/rule127.ts b/linter-4.2/test_rules/rule127.ts new file mode 100644 index 0000000000000000000000000000000000000000..903d61a6dc86bd3de2df6ecfdb721d7701af6194 --- /dev/null +++ b/linter-4.2/test_rules/rule127.ts @@ -0,0 +1,12 @@ + // 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-4.2/test_rules/rule127.ts.autofix.json b/linter-4.2/test_rules/rule127.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c32c0f461dd55626cd83972b7aa2a8d7bff66f60 --- /dev/null +++ b/linter-4.2/test_rules/rule127.ts.autofix.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "line": 12, + "column": 5, + "problem": "TypeOnlyExport", + "autofixable": true, + "autofix": [ + { + "start": 218, + "end": 240, + "replacementText": "export { Class2 };" + } + ], + "suggest": "", + "rule": "Special \"export type\" declarations are not supported (arkts-no-special-exports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule127.ts.relax.json b/linter-4.2/test_rules/rule127.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule127.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule127.ts.strict.json b/linter-4.2/test_rules/rule127.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..35f1a58896b2262887e713eb7ea091a5342d8b98 --- /dev/null +++ b/linter-4.2/test_rules/rule127.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 12, + "column": 5, + "problem": "TypeOnlyExport", + "suggest": "", + "rule": "Special \"export type\" declarations are not supported (arkts-no-special-exports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule128.ts b/linter-4.2/test_rules/rule128.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3b0dd6f07efd44b46a38fd5d4111da1316fc1e9 --- /dev/null +++ b/linter-4.2/test_rules/rule128.ts @@ -0,0 +1,3 @@ +declare module "someModule" { + export function normalize(s : string) : string; +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule128.ts.autofix.json b/linter-4.2/test_rules/rule128.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..fea184e9c5c766daefaee9d896b997cced09b619 --- /dev/null +++ b/linter-4.2/test_rules/rule128.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ShorthandAmbientModuleDecl", + "autofixable": false, + "suggest": "", + "rule": "Ambient module declaration is not supported (arkts-no-ambient-decls)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule128.ts.relax.json b/linter-4.2/test_rules/rule128.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..49937b6c77d4fe822746e682c0a50e59e36d9a1e --- /dev/null +++ b/linter-4.2/test_rules/rule128.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ShorthandAmbientModuleDecl", + "suggest": "", + "rule": "Ambient module declaration is not supported (arkts-no-ambient-decls)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule128.ts.strict.json b/linter-4.2/test_rules/rule128.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..49937b6c77d4fe822746e682c0a50e59e36d9a1e --- /dev/null +++ b/linter-4.2/test_rules/rule128.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ShorthandAmbientModuleDecl", + "suggest": "", + "rule": "Ambient module declaration is not supported (arkts-no-ambient-decls)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule129.ts b/linter-4.2/test_rules/rule129.ts new file mode 100644 index 0000000000000000000000000000000000000000..17703ba319d246a4e821460d19355f45fe2e4e44 --- /dev/null +++ b/linter-4.2/test_rules/rule129.ts @@ -0,0 +1,8 @@ + // Declaration: + declare module "*!text" { + const content: string + export default content + } + + // Consuming code: + import fileContent from "some.txt!text" \ No newline at end of file diff --git a/linter-4.2/test_rules/rule129.ts.autofix.json b/linter-4.2/test_rules/rule129.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..cd88007bd5b93c0d16da91d956cbe0da2b432b6a --- /dev/null +++ b/linter-4.2/test_rules/rule129.ts.autofix.json @@ -0,0 +1,43 @@ +{ + "nodes": [ + { + "line": 4, + "column": 9, + "problem": "NonDeclarationInNamespace", + "autofixable": false, + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + }, + { + "line": 2, + "column": 5, + "problem": "ShorthandAmbientModuleDecl", + "autofixable": false, + "suggest": "", + "rule": "Ambient module declaration is not supported (arkts-no-ambient-decls)" + }, + { + "line": 2, + "column": 5, + "problem": "WildcardsInModuleName", + "autofixable": false, + "suggest": "", + "rule": "Wildcards in module names are not supported (arkts-no-module-wildcards)" + }, + { + "line": 8, + "column": 5, + "problem": "ImportAfterStatement", + "autofixable": false, + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 2, + "column": 20, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Invalid module name in augmentation, module '*!text' cannot be found.", + "rule": "Invalid module name in augmentation, module '*!text' cannot be found." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule129.ts.relax.json b/linter-4.2/test_rules/rule129.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..498d178cb13bc3192b158e3cb13d63f8ac3e523a --- /dev/null +++ b/linter-4.2/test_rules/rule129.ts.relax.json @@ -0,0 +1,38 @@ +{ + "nodes": [ + { + "line": 4, + "column": 9, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + }, + { + "line": 2, + "column": 5, + "problem": "ShorthandAmbientModuleDecl", + "suggest": "", + "rule": "Ambient module declaration is not supported (arkts-no-ambient-decls)" + }, + { + "line": 2, + "column": 5, + "problem": "WildcardsInModuleName", + "suggest": "", + "rule": "Wildcards in module names are not supported (arkts-no-module-wildcards)" + }, + { + "line": 8, + "column": 5, + "problem": "ImportAfterStatement", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 2, + "column": 20, + "problem": "StrictDiagnostic", + "suggest": "Invalid module name in augmentation, module '*!text' cannot be found.", + "rule": "Invalid module name in augmentation, module '*!text' cannot be found." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule129.ts.strict.json b/linter-4.2/test_rules/rule129.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..498d178cb13bc3192b158e3cb13d63f8ac3e523a --- /dev/null +++ b/linter-4.2/test_rules/rule129.ts.strict.json @@ -0,0 +1,38 @@ +{ + "nodes": [ + { + "line": 4, + "column": 9, + "problem": "NonDeclarationInNamespace", + "suggest": "", + "rule": "Non-declaration statements in namespaces are not supported (arkts-no-ns-statements)" + }, + { + "line": 2, + "column": 5, + "problem": "ShorthandAmbientModuleDecl", + "suggest": "", + "rule": "Ambient module declaration is not supported (arkts-no-ambient-decls)" + }, + { + "line": 2, + "column": 5, + "problem": "WildcardsInModuleName", + "suggest": "", + "rule": "Wildcards in module names are not supported (arkts-no-module-wildcards)" + }, + { + "line": 8, + "column": 5, + "problem": "ImportAfterStatement", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 2, + "column": 20, + "problem": "StrictDiagnostic", + "suggest": "Invalid module name in augmentation, module '*!text' cannot be found.", + "rule": "Invalid module name in augmentation, module '*!text' cannot be found." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule13.ts b/linter-4.2/test_rules/rule13.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d38b7e3366a2a819785b2c29e10b05df684154a --- /dev/null +++ b/linter-4.2/test_rules/rule13.ts @@ -0,0 +1,8 @@ + +var t: [number, string] = [3, "three"] +var n = t[0] +var s = t[1] + +let a: Object[] = [3, "three"] +let b = a[0] +let c = a[1] \ No newline at end of file diff --git a/linter-4.2/test_rules/rule13.ts.autofix.json b/linter-4.2/test_rules/rule13.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..d82cefdf1514ba8556ea86b1f7d53834f089a305 --- /dev/null +++ b/linter-4.2/test_rules/rule13.ts.autofix.json @@ -0,0 +1,36 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 2, + "column": 8, + "problem": "TupleType", + "autofixable": false, + "suggest": "", + "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" + }, + { + "line": 3, + "column": 1, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 4, + "column": 1, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule13.ts.relax.json b/linter-4.2/test_rules/rule13.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..2e8a011be1d1d0c3c2b8d8cf907746ee703b4107 --- /dev/null +++ b/linter-4.2/test_rules/rule13.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 8, + "problem": "TupleType", + "suggest": "", + "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule13.ts.strict.json b/linter-4.2/test_rules/rule13.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..175484d2d31a84b15277490a58ffa76bd7885a5b --- /dev/null +++ b/linter-4.2/test_rules/rule13.ts.strict.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 2, + "column": 8, + "problem": "TupleType", + "suggest": "", + "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" + }, + { + "line": 3, + "column": 1, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 4, + "column": 1, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule130.ts b/linter-4.2/test_rules/rule130.ts new file mode 100644 index 0000000000000000000000000000000000000000..004066f8c895b43f52fe8d650858eab1ba050cef --- /dev/null +++ b/linter-4.2/test_rules/rule130.ts @@ -0,0 +1,6 @@ + // math-lib.d.ts + export const isPrime(x: number): boolean + export as namespace mathLib + + // in script + mathLib.isPrime(2) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule130.ts.autofix.json b/linter-4.2/test_rules/rule130.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..3d31ba721e0bab08cf1e9fcfa664957cec190aef --- /dev/null +++ b/linter-4.2/test_rules/rule130.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 2, + "column": 18, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 3, + "column": 5, + "problem": "UMDModuleDefinition", + "autofixable": false, + "suggest": "", + "rule": "Universal module definitions (UMD) are not supported (arkts-no-umd)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule130.ts.relax.json b/linter-4.2/test_rules/rule130.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..6877821bcbd7ffcc1715f3054a731d270be3cdde --- /dev/null +++ b/linter-4.2/test_rules/rule130.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 3, + "column": 5, + "problem": "UMDModuleDefinition", + "suggest": "", + "rule": "Universal module definitions (UMD) are not supported (arkts-no-umd)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule130.ts.strict.json b/linter-4.2/test_rules/rule130.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..6877821bcbd7ffcc1715f3054a731d270be3cdde --- /dev/null +++ b/linter-4.2/test_rules/rule130.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 18, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 3, + "column": 5, + "problem": "UMDModuleDefinition", + "suggest": "", + "rule": "Universal module definitions (UMD) are not supported (arkts-no-umd)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule132.ts b/linter-4.2/test_rules/rule132.ts new file mode 100644 index 0000000000000000000000000000000000000000..2791db7458b9c30c942ba9d5735dbdc5fb2426b3 --- /dev/null +++ b/linter-4.2/test_rules/rule132.ts @@ -0,0 +1,9 @@ +class CustomError extends Error { + constructor(message?: string) { + // 'Error' breaks prototype chain here: + super(message) + + // Restore prototype chain: + Object.setPrototypeOf(this, new.target.prototype) + } +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule132.ts.autofix.json b/linter-4.2/test_rules/rule132.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..9002b4276ade0505b91332d17e0d7c64608c6e8f --- /dev/null +++ b/linter-4.2/test_rules/rule132.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 7, + "column": 9, + "problem": "LimitedStdLibApi", + "autofixable": false, + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 7, + "column": 48, + "problem": "Prototype", + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 7, + "column": 37, + "problem": "NewTarget", + "autofixable": false, + "suggest": "", + "rule": "\"new.target\" is not supported (arkts-no-new-target)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule132.ts.relax.json b/linter-4.2/test_rules/rule132.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..192c3aa101f830da08961e07bd44fabed0c97d54 --- /dev/null +++ b/linter-4.2/test_rules/rule132.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 7, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 7, + "column": 48, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 7, + "column": 37, + "problem": "NewTarget", + "suggest": "", + "rule": "\"new.target\" is not supported (arkts-no-new-target)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule132.ts.strict.json b/linter-4.2/test_rules/rule132.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..192c3aa101f830da08961e07bd44fabed0c97d54 --- /dev/null +++ b/linter-4.2/test_rules/rule132.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 7, + "column": 9, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)" + }, + { + "line": 7, + "column": 48, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 7, + "column": 37, + "problem": "NewTarget", + "suggest": "", + "rule": "\"new.target\" is not supported (arkts-no-new-target)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule133.ts b/linter-4.2/test_rules/rule133.ts new file mode 100644 index 0000000000000000000000000000000000000000..255d5b5b738e649aa4e3223f0ae72d78a9dac444 --- /dev/null +++ b/linter-4.2/test_rules/rule133.ts @@ -0,0 +1 @@ +const zipUtil = await import("utils/create-zip-file") \ No newline at end of file diff --git a/linter-4.2/test_rules/rule133.ts.autofix.json b/linter-4.2/test_rules/rule133.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..932f141fbf8ea2d779f0ae07b11d76224491673a --- /dev/null +++ b/linter-4.2/test_rules/rule133.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "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-4.2/test_rules/rule133.ts.relax.json b/linter-4.2/test_rules/rule133.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..a15ec7e8730a8879739797ced7d2c348f715fc94 --- /dev/null +++ b/linter-4.2/test_rules/rule133.ts.relax.json @@ -0,0 +1,11 @@ +{ + "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-4.2/test_rules/rule133.ts.strict.json b/linter-4.2/test_rules/rule133.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..a15ec7e8730a8879739797ced7d2c348f715fc94 --- /dev/null +++ b/linter-4.2/test_rules/rule133.ts.strict.json @@ -0,0 +1,11 @@ +{ + "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-4.2/test_rules/rule134.ts b/linter-4.2/test_rules/rule134.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d7780e28342af9f9f998212bdf8ffa0dbce40d6 --- /dev/null +++ b/linter-4.2/test_rules/rule134.ts @@ -0,0 +1,9 @@ +let x!: number // Hint: x will be initialized before usage + +initialize() + +function initialize() { + x = 10 +} + +console.log("x = " + x) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule134.ts.autofix.json b/linter-4.2/test_rules/rule134.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..150cae524c44e4cbdb8de33e205f83a6e7bfc7fe --- /dev/null +++ b/linter-4.2/test_rules/rule134.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "DefiniteAssignment", + "autofixable": false, + "suggest": "", + "rule": "Definite assignment assertions are not supported (arkts-no-definite-assignment)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule134.ts.relax.json b/linter-4.2/test_rules/rule134.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..2c977321ce4f84bd2da8010e4b51373553900199 --- /dev/null +++ b/linter-4.2/test_rules/rule134.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "DefiniteAssignment", + "suggest": "", + "rule": "Definite assignment assertions are not supported (arkts-no-definite-assignment)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule134.ts.strict.json b/linter-4.2/test_rules/rule134.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..2c977321ce4f84bd2da8010e4b51373553900199 --- /dev/null +++ b/linter-4.2/test_rules/rule134.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "DefiniteAssignment", + "suggest": "", + "rule": "Definite assignment assertions are not supported (arkts-no-definite-assignment)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule135.ts b/linter-4.2/test_rules/rule135.ts new file mode 100644 index 0000000000000000000000000000000000000000..1912fcad2b334cd6e68b6dda529cef5a04c46462 --- /dev/null +++ b/linter-4.2/test_rules/rule135.ts @@ -0,0 +1,8 @@ +var C = (function() { + function C(n: number) { + this.p = n // Compile-time error only with noImplicitThis + } + C.staticProperty = 0 + return C +})() +C.staticProperty = 1 \ No newline at end of file diff --git a/linter-4.2/test_rules/rule135.ts.autofix.json b/linter-4.2/test_rules/rule135.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..f6875492b5e55dfa2250c42c73eea095d82f6097 --- /dev/null +++ b/linter-4.2/test_rules/rule135.ts.autofix.json @@ -0,0 +1,43 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 1, + "column": 10, + "problem": "FunctionExpression", + "autofixable": true, + "autofix": [ + { + "start": 9, + "end": 161, + "replacementText": "() => {\n function C(n: number) {\n this.p = n; // Compile-time error only with noImplicitThis\n }\n C.staticProperty = 0;\n return C;\n}" + } + ], + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + }, + { + "line": 2, + "column": 5, + "problem": "FunctionContainsThis", + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + }, + { + "line": 2, + "column": 5, + "problem": "LocalFunction", + "autofixable": false, + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule135.ts.relax.json b/linter-4.2/test_rules/rule135.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..772a1f628e47461607ed2422e22212586394fbc1 --- /dev/null +++ b/linter-4.2/test_rules/rule135.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule135.ts.strict.json b/linter-4.2/test_rules/rule135.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..7159087471035566f8d733bcf352d7e6ddc34b98 --- /dev/null +++ b/linter-4.2/test_rules/rule135.ts.strict.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 1, + "column": 10, + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + }, + { + "line": 2, + "column": 5, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + }, + { + "line": 2, + "column": 5, + "problem": "LocalFunction", + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule136.ts b/linter-4.2/test_rules/rule136.ts new file mode 100644 index 0000000000000000000000000000000000000000..41d0b50953924c05f2ff989b0b23d98f5c2f92b8 --- /dev/null +++ b/linter-4.2/test_rules/rule136.ts @@ -0,0 +1,13 @@ +var C = function(p: number) { + this.p = p // Compile-time error only with noImplicitThis +} + +C.prototype = { + m() { + console.log(this.p) + } +} + +C.prototype.q = function(r: number) { + return this.p == r +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule136.ts.autofix.json b/linter-4.2/test_rules/rule136.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..2ef10313e9b4370748cb0a3851512645430d22fc --- /dev/null +++ b/linter-4.2/test_rules/rule136.ts.autofix.json @@ -0,0 +1,68 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 1, + "column": 9, + "problem": "FunctionExpression", + "autofixable": false, + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + }, + { + "line": 1, + "column": 9, + "problem": "FunctionContainsThis", + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + }, + { + "line": 5, + "column": 3, + "problem": "Prototype", + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 5, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 11, + "column": 3, + "problem": "Prototype", + "autofixable": false, + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 11, + "column": 17, + "problem": "FunctionExpression", + "autofixable": false, + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + }, + { + "line": 11, + "column": 17, + "problem": "FunctionContainsThis", + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule136.ts.relax.json b/linter-4.2/test_rules/rule136.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..f048f98bec749afe14c3106c170a671431f23436 --- /dev/null +++ b/linter-4.2/test_rules/rule136.ts.relax.json @@ -0,0 +1,39 @@ +{ + "nodes": [ + { + "line": 1, + "column": 9, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + }, + { + "line": 5, + "column": 3, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 5, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 11, + "column": 3, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 11, + "column": 17, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule136.ts.strict.json b/linter-4.2/test_rules/rule136.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..aa5d42bb137681e95e123696fdfb96018a76816c --- /dev/null +++ b/linter-4.2/test_rules/rule136.ts.strict.json @@ -0,0 +1,60 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 1, + "column": 9, + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + }, + { + "line": 1, + "column": 9, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + }, + { + "line": 5, + "column": 3, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 5, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 11, + "column": 3, + "problem": "Prototype", + "suggest": "", + "rule": "Prototype assignment is not supported (arkts-no-prototype-assignment)" + }, + { + "line": 11, + "column": 17, + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + }, + { + "line": 11, + "column": 17, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule137.ts b/linter-4.2/test_rules/rule137.ts new file mode 100644 index 0000000000000000000000000000000000000000..32d166ee422ff67868a92599e13d729c051d5b7a --- /dev/null +++ b/linter-4.2/test_rules/rule137.ts @@ -0,0 +1,5 @@ + // in a global file: + var abc = 100 + + // Refers to 'abc' from above. + globalThis.abc = 200 \ No newline at end of file diff --git a/linter-4.2/test_rules/rule137.ts.autofix.json b/linter-4.2/test_rules/rule137.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..9a5bf848d4a2c41f79ac0faaecc88a11d49c091b --- /dev/null +++ b/linter-4.2/test_rules/rule137.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 5, + "column": 5, + "problem": "GlobalThis", + "autofixable": false, + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule137.ts.relax.json b/linter-4.2/test_rules/rule137.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..5ca44f4475d202e9c6d99a2211473861ccd455ae --- /dev/null +++ b/linter-4.2/test_rules/rule137.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 5, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule137.ts.strict.json b/linter-4.2/test_rules/rule137.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..2db3ea8257b81ff14ce0e679ce8555a2d74e469b --- /dev/null +++ b/linter-4.2/test_rules/rule137.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 5, + "column": 5, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule138.ts b/linter-4.2/test_rules/rule138.ts new file mode 100644 index 0000000000000000000000000000000000000000..7f0361417ef0e133b12a4744b6f03f223dfba51e --- /dev/null +++ b/linter-4.2/test_rules/rule138.ts @@ -0,0 +1,22 @@ +type Person = { + name: string + age: number + location: string +} + +type QuantumPerson = Omit + +let persons : Record = { + "Alice": { + name: "Alice", + age: 32, + location: "Shanghai" + }, + "Bob": { + name: "Bob", + age: 48, + location: "New York" + } +} +console.log(persons["Bob"].age) +console.log(persons["Rob"].age) // Runtime exception \ No newline at end of file diff --git a/linter-4.2/test_rules/rule138.ts.autofix.json b/linter-4.2/test_rules/rule138.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..7b5d895150f08eec4e428348a62f994f61e21ecb --- /dev/null +++ b/linter-4.2/test_rules/rule138.ts.autofix.json @@ -0,0 +1,36 @@ +{ + "nodes": [ + { + "line": 1, + "column": 15, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 7, + "column": 22, + "problem": "UtilityType", + "autofixable": false, + "suggest": "", + "rule": "Some of utility types are not supported (arkts-no-utility-types)" + }, + { + "line": 10, + "column": 14, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 15, + "column": 12, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "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-4.2/test_rules/rule138.ts.relax.json b/linter-4.2/test_rules/rule138.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..e8cfb5be2bb0c899e85744b8d6aee2fe8b4995cc --- /dev/null +++ b/linter-4.2/test_rules/rule138.ts.relax.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 1, + "column": 15, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 7, + "column": 22, + "problem": "UtilityType", + "suggest": "", + "rule": "Some of utility types are not supported (arkts-no-utility-types)" + }, + { + "line": 10, + "column": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 15, + "column": 12, + "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-4.2/test_rules/rule138.ts.strict.json b/linter-4.2/test_rules/rule138.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..e8cfb5be2bb0c899e85744b8d6aee2fe8b4995cc --- /dev/null +++ b/linter-4.2/test_rules/rule138.ts.strict.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 1, + "column": 15, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 7, + "column": 22, + "problem": "UtilityType", + "suggest": "", + "rule": "Some of utility types are not supported (arkts-no-utility-types)" + }, + { + "line": 10, + "column": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 15, + "column": 12, + "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-4.2/test_rules/rule139.ts b/linter-4.2/test_rules/rule139.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcbd60a52f244b7e315dd578edd847bdf74c954e --- /dev/null +++ b/linter-4.2/test_rules/rule139.ts @@ -0,0 +1,23 @@ +class MyImage { + // ... +} + +function readImage( + path: string, callback: (err: any, image: MyImage) => void +) +{ + // ... +} + +function readFileSync(path : string) : number[] { + return [] +} + +function decodeImageSync(contrents : number[]) { + // ... +} + +readImage.sync = (path: string) => { + const contents = readFileSync(path) + return decodeImageSync(contents) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule139.ts.autofix.json b/linter-4.2/test_rules/rule139.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..889c717b6ca43ea3988145aed051d7e3443656f0 --- /dev/null +++ b/linter-4.2/test_rules/rule139.ts.autofix.json @@ -0,0 +1,57 @@ +{ + "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": 6, + "column": 35, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "autofixable": false, + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, + { + "line": 20, + "column": 1, + "problem": "PropertyDeclOnFunction", + "autofixable": false, + "suggest": "", + "rule": "Declaring properties on functions is not supported (arkts-no-func-props)" + }, + { + "line": 20, + "column": 18, + "problem": "LimitedReturnTypeInference", + "autofixable": true, + "autofix": [ + { + "start": 292, + "end": 292, + "replacementText": ": void" + } + ], + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule139.ts.relax.json b/linter-4.2/test_rules/rule139.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..b7b7c9f37a09769d65176147832a357c71d72ac1 --- /dev/null +++ b/linter-4.2/test_rules/rule139.ts.relax.json @@ -0,0 +1,39 @@ +{ + "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": 6, + "column": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, + { + "line": 20, + "column": 1, + "problem": "PropertyDeclOnFunction", + "suggest": "", + "rule": "Declaring properties on functions is not supported (arkts-no-func-props)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule139.ts.strict.json b/linter-4.2/test_rules/rule139.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..29d46120970162586aceb5836230bd982d40e73d --- /dev/null +++ b/linter-4.2/test_rules/rule139.ts.strict.json @@ -0,0 +1,46 @@ +{ + "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": 6, + "column": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, + { + "line": 20, + "column": 1, + "problem": "PropertyDeclOnFunction", + "suggest": "", + "rule": "Declaring properties on functions is not supported (arkts-no-func-props)" + }, + { + "line": 20, + "column": 18, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule14.ts b/linter-4.2/test_rules/rule14.ts new file mode 100644 index 0000000000000000000000000000000000000000..c280a753d6e9423e6093664a3b0a89a5183a6cad --- /dev/null +++ b/linter-4.2/test_rules/rule14.ts @@ -0,0 +1,8 @@ +type DescribableFunction = { + description: string + (someArg: number): string // call signature +} + +function doSomething(fn: DescribableFunction): void { + console.log(fn.description + " returned " + fn(6)) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule14.ts.autofix.json b/linter-4.2/test_rules/rule14.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..2448bab5a0e9ee70d7f4f2e71e9e22510c32eab3 --- /dev/null +++ b/linter-4.2/test_rules/rule14.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 1, + "column": 28, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 3, + "column": 5, + "problem": "CallSignature", + "autofixable": false, + "suggest": "", + "rule": "Use \"class\" instead of a type with call signature (arkts-no-call-signatures)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule14.ts.relax.json b/linter-4.2/test_rules/rule14.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..37abba9056e531f46d6622ad8f5f5dc414414d92 --- /dev/null +++ b/linter-4.2/test_rules/rule14.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 28, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 3, + "column": 5, + "problem": "CallSignature", + "suggest": "", + "rule": "Use \"class\" instead of a type with call signature (arkts-no-call-signatures)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule14.ts.strict.json b/linter-4.2/test_rules/rule14.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..37abba9056e531f46d6622ad8f5f5dc414414d92 --- /dev/null +++ b/linter-4.2/test_rules/rule14.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 28, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 3, + "column": 5, + "problem": "CallSignature", + "suggest": "", + "rule": "Use \"class\" instead of a type with call signature (arkts-no-call-signatures)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule140.ts b/linter-4.2/test_rules/rule140.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcbd60a52f244b7e315dd578edd847bdf74c954e --- /dev/null +++ b/linter-4.2/test_rules/rule140.ts @@ -0,0 +1,23 @@ +class MyImage { + // ... +} + +function readImage( + path: string, callback: (err: any, image: MyImage) => void +) +{ + // ... +} + +function readFileSync(path : string) : number[] { + return [] +} + +function decodeImageSync(contrents : number[]) { + // ... +} + +readImage.sync = (path: string) => { + const contents = readFileSync(path) + return decodeImageSync(contents) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule140.ts.autofix.json b/linter-4.2/test_rules/rule140.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..889c717b6ca43ea3988145aed051d7e3443656f0 --- /dev/null +++ b/linter-4.2/test_rules/rule140.ts.autofix.json @@ -0,0 +1,57 @@ +{ + "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": 6, + "column": 35, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "autofixable": false, + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, + { + "line": 20, + "column": 1, + "problem": "PropertyDeclOnFunction", + "autofixable": false, + "suggest": "", + "rule": "Declaring properties on functions is not supported (arkts-no-func-props)" + }, + { + "line": 20, + "column": 18, + "problem": "LimitedReturnTypeInference", + "autofixable": true, + "autofix": [ + { + "start": 292, + "end": 292, + "replacementText": ": void" + } + ], + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule140.ts.relax.json b/linter-4.2/test_rules/rule140.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..b7b7c9f37a09769d65176147832a357c71d72ac1 --- /dev/null +++ b/linter-4.2/test_rules/rule140.ts.relax.json @@ -0,0 +1,39 @@ +{ + "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": 6, + "column": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, + { + "line": 20, + "column": 1, + "problem": "PropertyDeclOnFunction", + "suggest": "", + "rule": "Declaring properties on functions is not supported (arkts-no-func-props)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule140.ts.strict.json b/linter-4.2/test_rules/rule140.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..29d46120970162586aceb5836230bd982d40e73d --- /dev/null +++ b/linter-4.2/test_rules/rule140.ts.strict.json @@ -0,0 +1,46 @@ +{ + "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": 6, + "column": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, + { + "line": 20, + "column": 1, + "problem": "PropertyDeclOnFunction", + "suggest": "", + "rule": "Declaring properties on functions is not supported (arkts-no-func-props)" + }, + { + "line": 20, + "column": 18, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule141.ts b/linter-4.2/test_rules/rule141.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0ebc2f8428794c09de4b981903603faef933529 --- /dev/null +++ b/linter-4.2/test_rules/rule141.ts @@ -0,0 +1,4 @@ +function foo(arr: readonly string[]) { + arr.slice() // OK + arr.push("hello!") // Compile-time error +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule141.ts.autofix.json b/linter-4.2/test_rules/rule141.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..4843ef02e483bcebe356e13659b0b744669bc658 --- /dev/null +++ b/linter-4.2/test_rules/rule141.ts.autofix.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "line": 1, + "column": 19, + "problem": "ReadonlyArr", + "autofixable": true, + "autofix": [ + { + "start": 18, + "end": 35, + "replacementText": "string[]" + } + ], + "suggest": "", + "rule": "\"readonly T[]\" syntax is not supported (arkts-no-readonly-params)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule141.ts.relax.json b/linter-4.2/test_rules/rule141.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule141.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule141.ts.strict.json b/linter-4.2/test_rules/rule141.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..3d0ea495351117bd2c94275253dd750a713dc86d --- /dev/null +++ b/linter-4.2/test_rules/rule141.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 19, + "problem": "ReadonlyArr", + "suggest": "", + "rule": "\"readonly T[]\" syntax is not supported (arkts-no-readonly-params)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule142.ts b/linter-4.2/test_rules/rule142.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbccf5be8668331e4ec4a74d93feb574ffa239b3 --- /dev/null +++ b/linter-4.2/test_rules/rule142.ts @@ -0,0 +1,8 @@ + // Type 'hello': + let x = "hello" as const + + // Type 'readonly [10, 20]': + let y = [10, 20] as const + + // Type '{ readonly text: "hello" }': + let z = { text: "hello" } as const \ No newline at end of file diff --git a/linter-4.2/test_rules/rule142.ts.autofix.json b/linter-4.2/test_rules/rule142.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..8da6f5f88468f683b79bcb793ce48f7ecc365a62 --- /dev/null +++ b/linter-4.2/test_rules/rule142.ts.autofix.json @@ -0,0 +1,36 @@ +{ + "nodes": [ + { + "line": 2, + "column": 13, + "problem": "ConstAssertion", + "autofixable": false, + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 5, + "column": 13, + "problem": "ConstAssertion", + "autofixable": false, + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 8, + "column": 13, + "problem": "ConstAssertion", + "autofixable": false, + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 8, + "column": 13, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "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-4.2/test_rules/rule142.ts.relax.json b/linter-4.2/test_rules/rule142.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..f61e4269aaa8a99e7081a929cb2158ceb1878f00 --- /dev/null +++ b/linter-4.2/test_rules/rule142.ts.relax.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 2, + "column": 13, + "problem": "ConstAssertion", + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 5, + "column": 13, + "problem": "ConstAssertion", + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 8, + "column": 13, + "problem": "ConstAssertion", + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 8, + "column": 13, + "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-4.2/test_rules/rule142.ts.strict.json b/linter-4.2/test_rules/rule142.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..f61e4269aaa8a99e7081a929cb2158ceb1878f00 --- /dev/null +++ b/linter-4.2/test_rules/rule142.ts.strict.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 2, + "column": 13, + "problem": "ConstAssertion", + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 5, + "column": 13, + "problem": "ConstAssertion", + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 8, + "column": 13, + "problem": "ConstAssertion", + "suggest": "", + "rule": "\"as const\" assertions are not supported (arkts-no-as-const)" + }, + { + "line": 8, + "column": 13, + "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-4.2/test_rules/rule145.ts b/linter-4.2/test_rules/rule145.ts new file mode 100644 index 0000000000000000000000000000000000000000..74719e73db5cd5c93b6eaa2fddcd8241b8a2cc86 --- /dev/null +++ b/linter-4.2/test_rules/rule145.ts @@ -0,0 +1,16 @@ +class C { + n: number // Compile-time error only with strictPropertyInitialization + s: string // Compile-time error only with strictPropertyInitialization +} + +// Compile-time error only with noImplicitReturns +function foo(s: string): string { + if (s != "") { + console.log(s) + return s + } else { + console.log(s) + } +} + +let n: number = null // Compile-time error only with strictNullChecks \ No newline at end of file diff --git a/linter-4.2/test_rules/rule145.ts.autofix.json b/linter-4.2/test_rules/rule145.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..d5441fbcd7341079eaea72cbe3dd95186f547d07 --- /dev/null +++ b/linter-4.2/test_rules/rule145.ts.autofix.json @@ -0,0 +1,36 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Property 'n' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'n' has no initializer and is not definitely assigned in the constructor." + }, + { + "line": 3, + "column": 5, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Property 's' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 's' has no initializer and is not definitely assigned in the constructor." + }, + { + "line": 7, + "column": 26, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'." + }, + { + "line": 16, + "column": 5, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Type 'null' is not assignable to type 'number'.", + "rule": "Type 'null' is not assignable to type 'number'." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule145.ts.relax.json b/linter-4.2/test_rules/rule145.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..7a0139ed3bbd9ce5a0c63a7894bda5f7d293de64 --- /dev/null +++ b/linter-4.2/test_rules/rule145.ts.relax.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Property 'n' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'n' has no initializer and is not definitely assigned in the constructor." + }, + { + "line": 3, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Property 's' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 's' has no initializer and is not definitely assigned in the constructor." + }, + { + "line": 7, + "column": 26, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'." + }, + { + "line": 16, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number'.", + "rule": "Type 'null' is not assignable to type 'number'." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule145.ts.strict.json b/linter-4.2/test_rules/rule145.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..7a0139ed3bbd9ce5a0c63a7894bda5f7d293de64 --- /dev/null +++ b/linter-4.2/test_rules/rule145.ts.strict.json @@ -0,0 +1,32 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Property 'n' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 'n' has no initializer and is not definitely assigned in the constructor." + }, + { + "line": 3, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Property 's' has no initializer and is not definitely assigned in the constructor.", + "rule": "Property 's' has no initializer and is not definitely assigned in the constructor." + }, + { + "line": 7, + "column": 26, + "problem": "StrictDiagnostic", + "suggest": "Function lacks ending return statement and return type does not include 'undefined'.", + "rule": "Function lacks ending return statement and return type does not include 'undefined'." + }, + { + "line": 16, + "column": 5, + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number'.", + "rule": "Type 'null' is not assignable to type 'number'." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule146.ts b/linter-4.2/test_rules/rule146.ts new file mode 100644 index 0000000000000000000000000000000000000000..ce6a9f84446bf8e8a3ac91f02c494f72908e9742 --- /dev/null +++ b/linter-4.2/test_rules/rule146.ts @@ -0,0 +1,9 @@ + // @ts-nocheck + // ... + // Some code with switched off type checker + // ... + + let s1: string = null // No error, type checker suppressed + + // @ts-ignore + let s2: string = null // No error, type checker suppressed \ No newline at end of file diff --git a/linter-4.2/test_rules/rule146.ts.autofix.json b/linter-4.2/test_rules/rule146.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..f76f77acc1384f65d570e3e116591d3c09ccc50b --- /dev/null +++ b/linter-4.2/test_rules/rule146.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "ErrorSuppression", + "autofixable": false, + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + }, + { + "line": 8, + "column": 5, + "problem": "ErrorSuppression", + "autofixable": false, + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule146.ts.relax.json b/linter-4.2/test_rules/rule146.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..4cf4a17db8556c890b3a1b647efffd6d7ce602c6 --- /dev/null +++ b/linter-4.2/test_rules/rule146.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + }, + { + "line": 8, + "column": 5, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule146.ts.strict.json b/linter-4.2/test_rules/rule146.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..4cf4a17db8556c890b3a1b647efffd6d7ce602c6 --- /dev/null +++ b/linter-4.2/test_rules/rule146.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + }, + { + "line": 8, + "column": 5, + "problem": "ErrorSuppression", + "suggest": "", + "rule": "Switching off type checks with in-place comments is not allowed (arkts-strict-typing-required)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule147.ts b/linter-4.2/test_rules/rule147.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb9480d045213ae29fc238a3fb4618acaba15215 --- /dev/null +++ b/linter-4.2/test_rules/rule147.ts @@ -0,0 +1,7 @@ + // app.ets + export class C { + // ... + } + + // lib.ts + import { C } from "app" diff --git a/linter-4.2/test_rules/rule147.ts.autofix.json b/linter-4.2/test_rules/rule147.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..819d36d95dbe8467aa470cf1e0b34f80c10e3041 --- /dev/null +++ b/linter-4.2/test_rules/rule147.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "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": 7, + "column": 5, + "problem": "ImportAfterStatement", + "autofixable": false, + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 7, + "column": 14, + "problem": "DeclWithDuplicateName", + "autofixable": false, + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule147.ts.relax.json b/linter-4.2/test_rules/rule147.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..ad3d2d80ecee8dbc818d75da37f5724d470970e4 --- /dev/null +++ b/linter-4.2/test_rules/rule147.ts.relax.json @@ -0,0 +1,10 @@ +{ + "nodes": [ + { + "line": 7, + "column": 5, + "problem": "ImportAfterStatement", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule147.ts.strict.json b/linter-4.2/test_rules/rule147.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..99874461dd58d4c43e2effdc6b727ab36d596c20 --- /dev/null +++ b/linter-4.2/test_rules/rule147.ts.strict.json @@ -0,0 +1,32 @@ +{ + "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": 7, + "column": 5, + "problem": "ImportAfterStatement", + "suggest": "", + "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" + }, + { + "line": 7, + "column": 14, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule148.ts b/linter-4.2/test_rules/rule148.ts new file mode 100644 index 0000000000000000000000000000000000000000..1266c40595f0a5228c263ff44836619cc5c7dff3 --- /dev/null +++ b/linter-4.2/test_rules/rule148.ts @@ -0,0 +1,7 @@ +function classDecorator(x: any, y: any): void { + // +} + +@classDecorator +class BugReport { +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule148.ts.autofix.json b/linter-4.2/test_rules/rule148.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..5c410df051efb74a638b1a4dc97a3f817f12b9b8 --- /dev/null +++ b/linter-4.2/test_rules/rule148.ts.autofix.json @@ -0,0 +1,27 @@ +{ + "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)" + }, + { + "line": 5, + "column": 1, + "problem": "UnsupportedDecorators", + "autofixable": false, + "rule": "No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule148.ts.relax.json b/linter-4.2/test_rules/rule148.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..b2cd5b221fca720c733ac30fcb196001f1af7688 --- /dev/null +++ b/linter-4.2/test_rules/rule148.ts.relax.json @@ -0,0 +1,24 @@ +{ + "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)" + }, + { + "line": 5, + "column": 1, + "problem": "UnsupportedDecorators", + "rule": "No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule148.ts.strict.json b/linter-4.2/test_rules/rule148.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..b2cd5b221fca720c733ac30fcb196001f1af7688 --- /dev/null +++ b/linter-4.2/test_rules/rule148.ts.strict.json @@ -0,0 +1,24 @@ +{ + "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)" + }, + { + "line": 5, + "column": 1, + "problem": "UnsupportedDecorators", + "rule": "No decorators except ArkUI decorators are currently allowed (arkts-no-decorators-except-arkui)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule15.ts b/linter-4.2/test_rules/rule15.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a10c4869d554bb559c9a6a5f0591dde0c5b7a65 --- /dev/null +++ b/linter-4.2/test_rules/rule15.ts @@ -0,0 +1,21 @@ +class SomeObject {} + +type SomeConstructor = { + new (s: string): SomeObject +} + +function fn(ctor: SomeConstructor) { + return new ctor("hello") +} + + +class SomeObject2 { + public f: string + constructor (s: string) { + this.f = s + } +} + +function foo(s: string): SomeObject { + return new SomeObject2(s) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule15.ts.autofix.json b/linter-4.2/test_rules/rule15.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..84c2e59227951b482c0858fd92508a25edcc3783 --- /dev/null +++ b/linter-4.2/test_rules/rule15.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 3, + "column": 24, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 4, + "column": 5, + "problem": "ConstructorType", + "autofixable": false, + "suggest": "", + "rule": "Use \"class\" instead of a type with constructor signature (arkts-no-ctor-signatures-type)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule15.ts.relax.json b/linter-4.2/test_rules/rule15.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..523bca27d84ebea6615db5951ad50adcd246a6ea --- /dev/null +++ b/linter-4.2/test_rules/rule15.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 3, + "column": 24, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 4, + "column": 5, + "problem": "ConstructorType", + "suggest": "", + "rule": "Use \"class\" instead of a type with constructor signature (arkts-no-ctor-signatures-type)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule15.ts.strict.json b/linter-4.2/test_rules/rule15.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..523bca27d84ebea6615db5951ad50adcd246a6ea --- /dev/null +++ b/linter-4.2/test_rules/rule15.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 3, + "column": 24, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 4, + "column": 5, + "problem": "ConstructorType", + "suggest": "", + "rule": "Use \"class\" instead of a type with constructor signature (arkts-no-ctor-signatures-type)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule17.ts b/linter-4.2/test_rules/rule17.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed3d09638726002223d5bb01486171fdf29fcf32 --- /dev/null +++ b/linter-4.2/test_rules/rule17.ts @@ -0,0 +1,17 @@ +interface StringArray { + [index: number]: string +} + +function getStringArray() : StringArray { + return ["a", "b", "c"] +} + +const myArray: StringArray = getStringArray() +const secondItem = myArray[1] + +class Y { + public f: string[] = [] +} + +let myArray2: Y = new Y() +const secondItem2 = myArray2.f[1] \ No newline at end of file diff --git a/linter-4.2/test_rules/rule17.ts.autofix.json b/linter-4.2/test_rules/rule17.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..dcd0bb1a10489e014cc5d82fbb5af47c4c85657a --- /dev/null +++ b/linter-4.2/test_rules/rule17.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "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": 2, + "column": 5, + "problem": "IndexMember", + "autofixable": false, + "suggest": "", + "rule": "Indexed signatures are not supported (arkts-no-indexed-signatures)" + }, + { + "line": 10, + "column": 20, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule17.ts.relax.json b/linter-4.2/test_rules/rule17.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..43a5aef4c6ee01a2a045d8fbc8a2bcc2e6fd8945 --- /dev/null +++ b/linter-4.2/test_rules/rule17.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "IndexMember", + "suggest": "", + "rule": "Indexed signatures are not supported (arkts-no-indexed-signatures)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule17.ts.strict.json b/linter-4.2/test_rules/rule17.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..b998aa81e0ab52319c2dd736b7aa67b5e02105ce --- /dev/null +++ b/linter-4.2/test_rules/rule17.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "IndexMember", + "suggest": "", + "rule": "Indexed signatures are not supported (arkts-no-indexed-signatures)" + }, + { + "line": 10, + "column": 20, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule19.ts b/linter-4.2/test_rules/rule19.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3ec4340cc3276c764fbf2acbf42436a4fff54c7 --- /dev/null +++ b/linter-4.2/test_rules/rule19.ts @@ -0,0 +1,13 @@ +interface Identity { + id: number + name: string +} + +interface Contact { + email: string + phone: string +} + +type Employee = Identity & Contact + +interface Employee2 extends Identity, Contact {} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule19.ts.autofix.json b/linter-4.2/test_rules/rule19.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..2a5b7dbc5673019838fba3bbe8b359a3a5c3bd7e --- /dev/null +++ b/linter-4.2/test_rules/rule19.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 11, + "column": 17, + "problem": "IntersectionType", + "autofixable": false, + "suggest": "", + "rule": "Use inheritance instead of intersection types (arkts-no-intersection-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule19.ts.relax.json b/linter-4.2/test_rules/rule19.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..a3023753df1e1bff60766ab56138125a607085d4 --- /dev/null +++ b/linter-4.2/test_rules/rule19.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 11, + "column": 17, + "problem": "IntersectionType", + "suggest": "", + "rule": "Use inheritance instead of intersection types (arkts-no-intersection-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule19.ts.strict.json b/linter-4.2/test_rules/rule19.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..a3023753df1e1bff60766ab56138125a607085d4 --- /dev/null +++ b/linter-4.2/test_rules/rule19.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 11, + "column": 17, + "problem": "IntersectionType", + "suggest": "", + "rule": "Use inheritance instead of intersection types (arkts-no-intersection-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule2.ts b/linter-4.2/test_rules/rule2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7d5ced64437f22f0b310df2f8a468eef69347a35 --- /dev/null +++ b/linter-4.2/test_rules/rule2.ts @@ -0,0 +1,11 @@ + +const sym = Symbol() + +let o = { + [sym]: "value" +} + +class SomeClass { + public someProperty : string = "" +} +let z = new SomeClass() \ No newline at end of file diff --git a/linter-4.2/test_rules/rule2.ts.autofix.json b/linter-4.2/test_rules/rule2.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..7156573971ef42382f795c0fecafbfc6aa47a818 --- /dev/null +++ b/linter-4.2/test_rules/rule2.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 2, + "column": 13, + "problem": "SymbolType", + "autofixable": false, + "suggest": "", + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" + }, + { + "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-4.2/test_rules/rule2.ts.relax.json b/linter-4.2/test_rules/rule2.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..8d2f8bc1bc85ab64cfcd131422b8bfcd3a74c37d --- /dev/null +++ b/linter-4.2/test_rules/rule2.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 2, + "column": 13, + "problem": "SymbolType", + "suggest": "", + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" + }, + { + "line": 4, + "column": 9, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 5, + "column": 4, + "problem": "ComputedPropertyName", + "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-4.2/test_rules/rule2.ts.strict.json b/linter-4.2/test_rules/rule2.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..8d2f8bc1bc85ab64cfcd131422b8bfcd3a74c37d --- /dev/null +++ b/linter-4.2/test_rules/rule2.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 2, + "column": 13, + "problem": "SymbolType", + "suggest": "", + "rule": "\"Symbol()\" API is not supported (arkts-no-symbol)" + }, + { + "line": 4, + "column": 9, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 5, + "column": 4, + "problem": "ComputedPropertyName", + "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-4.2/test_rules/rule21.ts b/linter-4.2/test_rules/rule21.ts new file mode 100644 index 0000000000000000000000000000000000000000..aae13a788d9ea4a7aa2a9bc78ae5dac61e0d3475 --- /dev/null +++ b/linter-4.2/test_rules/rule21.ts @@ -0,0 +1,23 @@ +interface ListItem { + getHead(): this +} + +class C { + n: number = 0 + + m(c: this) { + console.log(c) + } +} + +interface ListItem2 { + getHead(): ListItem +} + +class D { + n: number = 0 + + m(c: D) { + console.log(c) + } +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule21.ts.autofix.json b/linter-4.2/test_rules/rule21.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..26da216ed955bbf311096ff6b14122691f136871 --- /dev/null +++ b/linter-4.2/test_rules/rule21.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 2, + "column": 16, + "problem": "ThisType", + "autofixable": false, + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)" + }, + { + "line": 8, + "column": 10, + "problem": "ThisType", + "autofixable": false, + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule21.ts.relax.json b/linter-4.2/test_rules/rule21.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..efb1a7a1615dfa54c27b4a706e6662093be916d7 --- /dev/null +++ b/linter-4.2/test_rules/rule21.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 16, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)" + }, + { + "line": 8, + "column": 10, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule21.ts.strict.json b/linter-4.2/test_rules/rule21.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..efb1a7a1615dfa54c27b4a706e6662093be916d7 --- /dev/null +++ b/linter-4.2/test_rules/rule21.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 16, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)" + }, + { + "line": 8, + "column": 10, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule22.ts b/linter-4.2/test_rules/rule22.ts new file mode 100644 index 0000000000000000000000000000000000000000..fede281ba093b29ebee28aab9e94ce632586a968 --- /dev/null +++ b/linter-4.2/test_rules/rule22.ts @@ -0,0 +1,7 @@ +type X = T extends number ? T : never + +type Y = T extends Array ? Item : never + +type X1 = T +type X2 = Object +type YI> = Item \ No newline at end of file diff --git a/linter-4.2/test_rules/rule22.ts.autofix.json b/linter-4.2/test_rules/rule22.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..2493216baed18cdaf6f38f1235441e5d50471a6d --- /dev/null +++ b/linter-4.2/test_rules/rule22.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 1, + "column": 13, + "problem": "ConditionalType", + "autofixable": false, + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)" + }, + { + "line": 3, + "column": 13, + "problem": "ConditionalType", + "autofixable": false, + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)" + } + ] +} diff --git a/linter-4.2/test_rules/rule22.ts.relax.json b/linter-4.2/test_rules/rule22.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..4e1ebe000e5022b48ccfe04d16f20ce2300e3c6f --- /dev/null +++ b/linter-4.2/test_rules/rule22.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 13, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)" + }, + { + "line": 3, + "column": 13, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)" + } + ] +} diff --git a/linter-4.2/test_rules/rule22.ts.strict.json b/linter-4.2/test_rules/rule22.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..4e1ebe000e5022b48ccfe04d16f20ce2300e3c6f --- /dev/null +++ b/linter-4.2/test_rules/rule22.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 13, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)" + }, + { + "line": 3, + "column": 13, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)" + } + ] +} diff --git a/linter-4.2/test_rules/rule25.ts b/linter-4.2/test_rules/rule25.ts new file mode 100644 index 0000000000000000000000000000000000000000..a485b8eb2e68e663428d96a9115e620de0c63f3d --- /dev/null +++ b/linter-4.2/test_rules/rule25.ts @@ -0,0 +1,31 @@ +class Person { + constructor( + protected ssn: string, + private firstName: string, + private lastName: string + ) { + this.ssn = ssn + this.firstName = firstName + this.lastName = lastName + } + + getFullName(): string { + return this.firstName + " " + this.lastName + } +} + +class Person2{ + protected ssn: string + private firstName: string + private lastName: string + + constructor(ssn: string, firstName: string, lastName: string) { + this.ssn = ssn + this.firstName = firstName + this.lastName = lastName + } + + getFullName(): string { + return this.firstName + " " + this.lastName + } +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule25.ts.autofix.json b/linter-4.2/test_rules/rule25.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..4f15af43d3cd4d47c0002ae821eac58ee1385e8b --- /dev/null +++ b/linter-4.2/test_rules/rule25.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 3, + "column": 9, + "problem": "ParameterProperties", + "autofixable": false, + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 4, + "column": 9, + "problem": "ParameterProperties", + "autofixable": false, + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 5, + "column": 9, + "problem": "ParameterProperties", + "autofixable": false, + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule25.ts.relax.json b/linter-4.2/test_rules/rule25.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule25.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule25.ts.strict.json b/linter-4.2/test_rules/rule25.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..ec5820fcb3a10c4279732c61211e0e0f21f011d1 --- /dev/null +++ b/linter-4.2/test_rules/rule25.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 3, + "column": 9, + "problem": "ParameterProperties", + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 4, + "column": 9, + "problem": "ParameterProperties", + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + }, + { + "line": 5, + "column": 9, + "problem": "ParameterProperties", + "suggest": "", + "rule": "Declaring fields in \"constructor\" is not supported (arkts-no-ctor-prop-decls)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule27.ts b/linter-4.2/test_rules/rule27.ts new file mode 100644 index 0000000000000000000000000000000000000000..b9c737db94799932d5847d36f1756e64883251a6 --- /dev/null +++ b/linter-4.2/test_rules/rule27.ts @@ -0,0 +1,15 @@ +interface I { + new (s: string): I +} + +function fn(i: I) { + return new i("hello") +} + +interface I2 { + create(s: string): I +} + +function foo(i: I2) { + return i.create("hello") +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule27.ts.autofix.json b/linter-4.2/test_rules/rule27.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..cddbb344b8273a7e453a7a5a1a49760d67fbce76 --- /dev/null +++ b/linter-4.2/test_rules/rule27.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "ConstructorIface", + "autofixable": false, + "suggest": "", + "rule": "Construct signatures are not supported in interfaces (arkts-no-ctor-signatures-iface)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule27.ts.relax.json b/linter-4.2/test_rules/rule27.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..9086d3bbcf2187193329b1cd689b514b3f08c760 --- /dev/null +++ b/linter-4.2/test_rules/rule27.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "ConstructorIface", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces (arkts-no-ctor-signatures-iface)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule27.ts.strict.json b/linter-4.2/test_rules/rule27.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..9086d3bbcf2187193329b1cd689b514b3f08c760 --- /dev/null +++ b/linter-4.2/test_rules/rule27.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "ConstructorIface", + "suggest": "", + "rule": "Construct signatures are not supported in interfaces (arkts-no-ctor-signatures-iface)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule28.ts b/linter-4.2/test_rules/rule28.ts new file mode 100644 index 0000000000000000000000000000000000000000..243f640fdac14ec304171ec687cdc61d09a1cd9c --- /dev/null +++ b/linter-4.2/test_rules/rule28.ts @@ -0,0 +1,5 @@ +type Point = {x: number, y: number} +type N = Point["x"] // is equal to number + +class Point2 {x: number = 0; y: number = 0} +type N2 = number \ No newline at end of file diff --git a/linter-4.2/test_rules/rule28.ts.autofix.json b/linter-4.2/test_rules/rule28.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..8f301783237a1e506aeda91686a17dac8526616f --- /dev/null +++ b/linter-4.2/test_rules/rule28.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 1, + "column": 14, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 2, + "column": 10, + "problem": "IndexedAccessType", + "autofixable": false, + "suggest": "", + "rule": "Indexed access types are not supported (arkts-no-aliases-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule28.ts.relax.json b/linter-4.2/test_rules/rule28.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..df9d49b8d04ea7df4a1343070165a5116a860be0 --- /dev/null +++ b/linter-4.2/test_rules/rule28.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 14, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 2, + "column": 10, + "problem": "IndexedAccessType", + "suggest": "", + "rule": "Indexed access types are not supported (arkts-no-aliases-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule28.ts.strict.json b/linter-4.2/test_rules/rule28.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..df9d49b8d04ea7df4a1343070165a5116a860be0 --- /dev/null +++ b/linter-4.2/test_rules/rule28.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 14, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 2, + "column": 10, + "problem": "IndexedAccessType", + "suggest": "", + "rule": "Indexed access types are not supported (arkts-no-aliases-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule29.ts b/linter-4.2/test_rules/rule29.ts new file mode 100644 index 0000000000000000000000000000000000000000..b476ec4e2fc16bb5a5cde163e07915d0efb55fc8 --- /dev/null +++ b/linter-4.2/test_rules/rule29.ts @@ -0,0 +1,7 @@ +class Point {x: number = 0; y: number = 0} +let p: Point = {x: 1, y: 2} +let x = p["x"] + +class Point2 {x: number = 0; y: number = 0} +let p2: Point2 = {x: 1, y: 2} +let x2 = p.x \ No newline at end of file diff --git a/linter-4.2/test_rules/rule29.ts.autofix.json b/linter-4.2/test_rules/rule29.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..7ce06f06c2b63c11a7b60f4d0f4051c4993d2f6a --- /dev/null +++ b/linter-4.2/test_rules/rule29.ts.autofix.json @@ -0,0 +1,26 @@ +{ + "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": 3, + "column": 9, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule29.ts.relax.json b/linter-4.2/test_rules/rule29.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule29.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule29.ts.strict.json b/linter-4.2/test_rules/rule29.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..be0431cb9e49770f0dff58158d3354f3a2b31923 --- /dev/null +++ b/linter-4.2/test_rules/rule29.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 3, + "column": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule3.ts b/linter-4.2/test_rules/rule3.ts new file mode 100644 index 0000000000000000000000000000000000000000..d01c13ee32ff28bf465ff748025f6e58c52ecb35 --- /dev/null +++ b/linter-4.2/test_rules/rule3.ts @@ -0,0 +1,8 @@ + +class C { + #foo: number = 42 +} + +class X { + private foo: number = 42 +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule3.ts.autofix.json b/linter-4.2/test_rules/rule3.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..447f6a26381a2d26437f73f966a0514e7f91a95f --- /dev/null +++ b/linter-4.2/test_rules/rule3.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 3, + "column": 5, + "problem": "PrivateIdentifier", + "autofixable": false, + "suggest": "", + "rule": "Private '#' identifiers are not supported (arkts-no-private-identifiers)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule3.ts.relax.json b/linter-4.2/test_rules/rule3.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule3.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule3.ts.strict.json b/linter-4.2/test_rules/rule3.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..92ea8921fec3d08fb424840e1a6be355ca3bdcbf --- /dev/null +++ b/linter-4.2/test_rules/rule3.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 3, + "column": 5, + "problem": "PrivateIdentifier", + "suggest": "", + "rule": "Private '#' identifiers are not supported (arkts-no-private-identifiers)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule30.ts b/linter-4.2/test_rules/rule30.ts new file mode 100644 index 0000000000000000000000000000000000000000..3204b6f832de1a06194b11629896f04fca9ad49e --- /dev/null +++ b/linter-4.2/test_rules/rule30.ts @@ -0,0 +1,9 @@ +interface X { + f(): string +} + +interface Y { + f(): string +} + +type Z = X \ No newline at end of file diff --git a/linter-4.2/test_rules/rule30.ts.autofix.json b/linter-4.2/test_rules/rule30.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule30.ts.autofix.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule30.ts.relax.json b/linter-4.2/test_rules/rule30.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule30.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule30.ts.strict.json b/linter-4.2/test_rules/rule30.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule30.ts.strict.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule31.ts b/linter-4.2/test_rules/rule31.ts new file mode 100644 index 0000000000000000000000000000000000000000..b939cad5b96240559b3b9975bde17fdf4affc678 --- /dev/null +++ b/linter-4.2/test_rules/rule31.ts @@ -0,0 +1,24 @@ +class X { + public foo: number + + constructor() { + this.foo = 0 + } +} + +class Y { + public foo: number + + constructor() { + this.foo = 0 + } +} + +let x = new X() +let y = new Y() + +console.log("Assign X to Y") +y = x + +console.log("Assign Y to X") +x = y \ No newline at end of file diff --git a/linter-4.2/test_rules/rule31.ts.autofix.json b/linter-4.2/test_rules/rule31.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..93738805a7df6e3e2207d426cf229e22c910930f --- /dev/null +++ b/linter-4.2/test_rules/rule31.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "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": 21, + "column": 1, + "problem": "StructuralIdentity", + "autofixable": false, + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + }, + { + "line": 24, + "column": 1, + "problem": "StructuralIdentity", + "autofixable": false, + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule31.ts.relax.json b/linter-4.2/test_rules/rule31.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..278f67e075e50e473695d02ccecd87d657eecd35 --- /dev/null +++ b/linter-4.2/test_rules/rule31.ts.relax.json @@ -0,0 +1,32 @@ +{ + "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": 21, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + }, + { + "line": 24, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule31.ts.strict.json b/linter-4.2/test_rules/rule31.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..278f67e075e50e473695d02ccecd87d657eecd35 --- /dev/null +++ b/linter-4.2/test_rules/rule31.ts.strict.json @@ -0,0 +1,32 @@ +{ + "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": 21, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + }, + { + "line": 24, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule32.ts b/linter-4.2/test_rules/rule32.ts new file mode 100644 index 0000000000000000000000000000000000000000..24005d7aa796a3e3fad5b8bcce787dd20a46e7b3 --- /dev/null +++ b/linter-4.2/test_rules/rule32.ts @@ -0,0 +1,57 @@ +class X { + public foo: number + + constructor() { + this.foo = 0 + } +} + +class Y { + public foo: number + constructor() { + this.foo = 0 + } +} + +let x = new X() +let y = new Y() + +console.log("Assign X to Y") +y = x + +console.log("Assign Y to X") +x = y + + + + +interface Z { + foo: number + } + + // X implements interface Z, which makes relation between X and Y explicit. + class C implements Z { + public foo: number + + constructor() { + this.foo = 0 + } + } + + // Y implements interface Z, which makes relation between X and Y explicit. + class C2 implements Z { + public foo: number + + constructor() { + this.foo = 0 + } + } + + let x1: Z = new C() + let y1: Z = new C2() + + console.log("Assign X to Y") + y1 = x1 // ok, both are of the same type + + console.log("Assign Y to X") + x1 = y1 // ok, both are of the same type \ No newline at end of file diff --git a/linter-4.2/test_rules/rule32.ts.autofix.json b/linter-4.2/test_rules/rule32.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..a932e2c692195391c6df4a6cf944922cf4c82ddb --- /dev/null +++ b/linter-4.2/test_rules/rule32.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "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": 20, + "column": 1, + "problem": "StructuralIdentity", + "autofixable": false, + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + }, + { + "line": 23, + "column": 1, + "problem": "StructuralIdentity", + "autofixable": false, + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule32.ts.relax.json b/linter-4.2/test_rules/rule32.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..6446311e96b34209987d92c55030890877d3263b --- /dev/null +++ b/linter-4.2/test_rules/rule32.ts.relax.json @@ -0,0 +1,32 @@ +{ + "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": 20, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + }, + { + "line": 23, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule32.ts.strict.json b/linter-4.2/test_rules/rule32.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..6446311e96b34209987d92c55030890877d3263b --- /dev/null +++ b/linter-4.2/test_rules/rule32.ts.strict.json @@ -0,0 +1,32 @@ +{ + "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": 20, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + }, + { + "line": 23, + "column": 1, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule34.ts b/linter-4.2/test_rules/rule34.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc20b813fb9e88ab5a83ed2b595b495062b3e710 --- /dev/null +++ b/linter-4.2/test_rules/rule34.ts @@ -0,0 +1,13 @@ +function choose(x: T, y: T): T { + return Math.random() < 0.5 ? x : y +} + +let x = choose(10, 20) +let y = choose("10", 20) + +function greet(): T { + return "Hello" as T +} +let z = greet() + +let p = greet() \ No newline at end of file diff --git a/linter-4.2/test_rules/rule34.ts.autofix.json b/linter-4.2/test_rules/rule34.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..669ab4d6a44daac45cbfa967ff783864ae37bbb8 --- /dev/null +++ b/linter-4.2/test_rules/rule34.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 11, + "column": 5, + "problem": "UnknownType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 9, + "problem": "GenericCallNoTypeArgs", + "autofixable": false, + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule34.ts.relax.json b/linter-4.2/test_rules/rule34.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..b5ec7e88397e3d844d13497aa4a5d31bc0c0ca3d --- /dev/null +++ b/linter-4.2/test_rules/rule34.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 11, + "column": 5, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 9, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule34.ts.strict.json b/linter-4.2/test_rules/rule34.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..b5ec7e88397e3d844d13497aa4a5d31bc0c0ca3d --- /dev/null +++ b/linter-4.2/test_rules/rule34.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 11, + "column": 5, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 9, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule35.ts b/linter-4.2/test_rules/rule35.ts new file mode 100644 index 0000000000000000000000000000000000000000..a93a28ef138b2a3f1bcfed6fb7778fc44251670f --- /dev/null +++ b/linter-4.2/test_rules/rule35.ts @@ -0,0 +1,31 @@ +class X { + public foo: number + private s: string + + constructor (f: number) { + this.foo = f + this.s = "" + } + + public say(): void { + console.log("X = ", this.foo) + } +} + +class Y { + public foo: number + + constructor (f: number) { + this.foo = f + } + public say(): void { + console.log("Y = ", this.foo) + } +} + +function bar(z: X): void { + z.say() +} + +bar(new X(1)) +bar(new Y(2) as X) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule35.ts.autofix.json b/linter-4.2/test_rules/rule35.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..b58aa1b185222f8038191a96680f00b1f7c7de9e --- /dev/null +++ b/linter-4.2/test_rules/rule35.ts.autofix.json @@ -0,0 +1,26 @@ +{ + "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": 31, + "column": 5, + "problem": "StructuralIdentity", + "autofixable": false, + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule35.ts.relax.json b/linter-4.2/test_rules/rule35.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..f2b48d95a67d9862e0165b3bde40d481d2e1ed27 --- /dev/null +++ b/linter-4.2/test_rules/rule35.ts.relax.json @@ -0,0 +1,25 @@ +{ + "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": 31, + "column": 5, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule35.ts.strict.json b/linter-4.2/test_rules/rule35.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..f2b48d95a67d9862e0165b3bde40d481d2e1ed27 --- /dev/null +++ b/linter-4.2/test_rules/rule35.ts.strict.json @@ -0,0 +1,25 @@ +{ + "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": 31, + "column": 5, + "problem": "StructuralIdentity", + "suggest": "", + "rule": "Structural typing is not supported (arkts-no-structural-typing)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule37.ts b/linter-4.2/test_rules/rule37.ts new file mode 100644 index 0000000000000000000000000000000000000000..b39b996cab6b297f2d8b69be72552922e1ae3297 --- /dev/null +++ b/linter-4.2/test_rules/rule37.ts @@ -0,0 +1,3 @@ +let regex: RegExp = /bc*d/ + +let regex2: RegExp = new RegExp("/bc*d/") \ No newline at end of file diff --git a/linter-4.2/test_rules/rule37.ts.autofix.json b/linter-4.2/test_rules/rule37.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..b7626c51f359fd3f0850bbfab7d8ff6c60366c8d --- /dev/null +++ b/linter-4.2/test_rules/rule37.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 1, + "column": 21, + "problem": "RegexLiteral", + "autofixable": false, + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule37.ts.relax.json b/linter-4.2/test_rules/rule37.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..f4fac00b6956402370b28b9017b162bd1160966b --- /dev/null +++ b/linter-4.2/test_rules/rule37.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 21, + "problem": "RegexLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule37.ts.strict.json b/linter-4.2/test_rules/rule37.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..f4fac00b6956402370b28b9017b162bd1160966b --- /dev/null +++ b/linter-4.2/test_rules/rule37.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 21, + "problem": "RegexLiteral", + "suggest": "", + "rule": "RegExp literals are not supported (arkts-no-regexp-literals)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule38.ts b/linter-4.2/test_rules/rule38.ts new file mode 100644 index 0000000000000000000000000000000000000000..41be78fe3650d387d81eb41807be6ede120edef7 --- /dev/null +++ b/linter-4.2/test_rules/rule38.ts @@ -0,0 +1,53 @@ +class C1 { + n: number = 0 + s: string = "" +} + +let o1: C1 = {n: 42, s: "foo"} +let o2: C1 = {n: 42, s: "foo"} +let o3: C1 = {n: 42, s: "foo"} + +let oo: C1[] = [{n: 1, s: "1"}, {n: 2, s: "2"}] + +class C2 { + s: string + constructor(s: string) { + this.s = "s =" + s + } +} +let o4 = new C2("foo") + +class C3 { + n: number = 0 + s: string = "" +} +let o5: C3 = {n: 42, s: "foo"} + +abstract class A {} +class C extends A {} +let o6: C = {} + +class C4 { + n: number = 0 + s: string = "" + f() { + console.log("Hello") + } +} +let o7 = new C4() +o7.n = 42 +o7.s = "foo" + +class Point { + x: number = 0 + y: number = 0 +} + +function id_x_y(o: Point): Point { + return o +} + +let p: Point = {x: 5, y: 10} +id_x_y(p) + +id_x_y({x: 5, y: 10}) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule38.ts.autofix.json b/linter-4.2/test_rules/rule38.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule38.ts.autofix.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule38.ts.relax.json b/linter-4.2/test_rules/rule38.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule38.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule38.ts.strict.json b/linter-4.2/test_rules/rule38.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule38.ts.strict.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule4.ts b/linter-4.2/test_rules/rule4.ts new file mode 100644 index 0000000000000000000000000000000000000000..269e702b5a560fc6d2bd628252762f9d546af32e --- /dev/null +++ b/linter-4.2/test_rules/rule4.ts @@ -0,0 +1,2 @@ +let X: string +type X = number[] \ No newline at end of file diff --git a/linter-4.2/test_rules/rule4.ts.autofix.json b/linter-4.2/test_rules/rule4.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..ba15a33cf59aebf7b21ab330280fe27cab3ac874 --- /dev/null +++ b/linter-4.2/test_rules/rule4.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "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": 1, + "column": 5, + "problem": "DeclWithDuplicateName", + "autofixable": false, + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + }, + { + "line": 2, + "column": 1, + "problem": "DeclWithDuplicateName", + "autofixable": false, + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule4.ts.relax.json b/linter-4.2/test_rules/rule4.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule4.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule4.ts.strict.json b/linter-4.2/test_rules/rule4.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..9dda4cf2161cbbdb25d061ecd071e1d6774d6fdb --- /dev/null +++ b/linter-4.2/test_rules/rule4.ts.strict.json @@ -0,0 +1,32 @@ +{ + "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": 1, + "column": 5, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + }, + { + "line": 2, + "column": 1, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule40.ts b/linter-4.2/test_rules/rule40.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d4ab0378bb36dc08f3fa3594700fee7026ea580 --- /dev/null +++ b/linter-4.2/test_rules/rule40.ts @@ -0,0 +1,15 @@ +let o: {x: number, y: number} = { + x: 2, + y: 3 +} + +type S = Set<{x: number, y: number}> + +class C { + x: number = 0 + y: number = 0 +} + +let c: C = {x: 2, y: 3} + +type t = Set \ No newline at end of file diff --git a/linter-4.2/test_rules/rule40.ts.autofix.json b/linter-4.2/test_rules/rule40.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..8acc6b2c94d32a75a79b67c5cbc2c30c44786b67 --- /dev/null +++ b/linter-4.2/test_rules/rule40.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 1, + "column": 8, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 1, + "column": 33, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 6, + "column": 14, + "problem": "ObjectTypeLiteral", + "autofixable": false, + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule40.ts.relax.json b/linter-4.2/test_rules/rule40.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..77aeae7181477787cf77a86d742ef479d4b00f60 --- /dev/null +++ b/linter-4.2/test_rules/rule40.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 8, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 1, + "column": 33, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 6, + "column": 14, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule40.ts.strict.json b/linter-4.2/test_rules/rule40.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..77aeae7181477787cf77a86d742ef479d4b00f60 --- /dev/null +++ b/linter-4.2/test_rules/rule40.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 8, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + }, + { + "line": 1, + "column": 33, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 6, + "column": 14, + "problem": "ObjectTypeLiteral", + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule43.ts b/linter-4.2/test_rules/rule43.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6b541f6c2d59383da174e75bed4866f575d2f8d --- /dev/null +++ b/linter-4.2/test_rules/rule43.ts @@ -0,0 +1,9 @@ +let a = [{n: 1, s: "1"}, {n: 2, s : "2"}] + +class C { + n: number = 0 + s: string = "" +} + +let a1 = [{n: 1, s: "1"} as C, {n: 2, s : "2"} as C] +let a2: C[] = [{n: 1, s: "1"}, {n: 2, s : "2"}] \ No newline at end of file diff --git a/linter-4.2/test_rules/rule43.ts.autofix.json b/linter-4.2/test_rules/rule43.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..dd7966c878fc748059980fcdb7852cad035a3c52 --- /dev/null +++ b/linter-4.2/test_rules/rule43.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 1, + "column": 9, + "problem": "ArrayLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Array literals must contain elements of only inferrable types (arkts-no-noninferrable-arr-literals)" + }, + { + "line": 1, + "column": 10, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 1, + "column": 26, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "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-4.2/test_rules/rule43.ts.relax.json b/linter-4.2/test_rules/rule43.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..07184c23ac02716e2e43bd36d502eb9cbdaef1cf --- /dev/null +++ b/linter-4.2/test_rules/rule43.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 9, + "problem": "ArrayLiteralNoContextType", + "suggest": "", + "rule": "Array literals must contain elements of only inferrable types (arkts-no-noninferrable-arr-literals)" + }, + { + "line": 1, + "column": 10, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 1, + "column": 26, + "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-4.2/test_rules/rule43.ts.strict.json b/linter-4.2/test_rules/rule43.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..07184c23ac02716e2e43bd36d502eb9cbdaef1cf --- /dev/null +++ b/linter-4.2/test_rules/rule43.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 9, + "problem": "ArrayLiteralNoContextType", + "suggest": "", + "rule": "Array literals must contain elements of only inferrable types (arkts-no-noninferrable-arr-literals)" + }, + { + "line": 1, + "column": 10, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 1, + "column": 26, + "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-4.2/test_rules/rule45.ts b/linter-4.2/test_rules/rule45.ts new file mode 100644 index 0000000000000000000000000000000000000000..8816b00216735e698ba1f0bac994caf36f0fedd1 --- /dev/null +++ b/linter-4.2/test_rules/rule45.ts @@ -0,0 +1,8 @@ + +let f = (s /* type any is assumed */) => { + console.log(s) +} + +let foo = (s: string) => { + console.log(s) +} diff --git a/linter-4.2/test_rules/rule45.ts.autofix.json b/linter-4.2/test_rules/rule45.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..b07ed33fd80291456ce2ab3e65de0c0eec82bee2 --- /dev/null +++ b/linter-4.2/test_rules/rule45.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "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-4.2/test_rules/rule45.ts.relax.json b/linter-4.2/test_rules/rule45.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..af6deaf3cde344e77629e64fdf30788ff8eeeccf --- /dev/null +++ b/linter-4.2/test_rules/rule45.ts.relax.json @@ -0,0 +1,11 @@ +{ + "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-4.2/test_rules/rule45.ts.strict.json b/linter-4.2/test_rules/rule45.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..af6deaf3cde344e77629e64fdf30788ff8eeeccf --- /dev/null +++ b/linter-4.2/test_rules/rule45.ts.strict.json @@ -0,0 +1,11 @@ +{ + "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-4.2/test_rules/rule46.ts b/linter-4.2/test_rules/rule46.ts new file mode 100644 index 0000000000000000000000000000000000000000..3032950f96a74304143a86a7b7541918db57bd82 --- /dev/null +++ b/linter-4.2/test_rules/rule46.ts @@ -0,0 +1,7 @@ +let f = function (s: string) { + console.log(s) +} + +let foo = (s: string) => { + console.log(s) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule46.ts.autofix.json b/linter-4.2/test_rules/rule46.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c3b09f54a99b75ef3ba69b222640f9af6d6c5286 --- /dev/null +++ b/linter-4.2/test_rules/rule46.ts.autofix.json @@ -0,0 +1,19 @@ +{ + "nodes": [ + { + "line": 1, + "column": 9, + "problem": "FunctionExpression", + "autofixable": true, + "autofix": [ + { + "start": 8, + "end": 51, + "replacementText": "(s: string) => {\n console.log(s);\n}" + } + ], + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule46.ts.relax.json b/linter-4.2/test_rules/rule46.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule46.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule46.ts.strict.json b/linter-4.2/test_rules/rule46.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..de176917c17a19bb1c1e66ece3c282ee3ffe10fc --- /dev/null +++ b/linter-4.2/test_rules/rule46.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 9, + "problem": "FunctionExpression", + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule49.ts b/linter-4.2/test_rules/rule49.ts new file mode 100644 index 0000000000000000000000000000000000000000..9510d5d91c54fbd589c472ca9065114ec12eaee4 --- /dev/null +++ b/linter-4.2/test_rules/rule49.ts @@ -0,0 +1,9 @@ +let generic_arrow_func = (x: T) => { return x } + +generic_arrow_func("string") + +function generic_func(x: T): T { + return x +} + +generic_func("string") \ No newline at end of file diff --git a/linter-4.2/test_rules/rule49.ts.autofix.json b/linter-4.2/test_rules/rule49.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..10a861657f4f27da022d1dd867264e93f4d75091 --- /dev/null +++ b/linter-4.2/test_rules/rule49.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 1, + "column": 26, + "problem": "LambdaWithTypeParameters", + "autofixable": false, + "suggest": "", + "rule": "Use generic functions instead of generic arrow functions (arkts-no-generic-lambdas)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule49.ts.relax.json b/linter-4.2/test_rules/rule49.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule49.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule49.ts.strict.json b/linter-4.2/test_rules/rule49.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..f2c3c0bfb8ea6fe8bc60ce92802fba6aa242cf41 --- /dev/null +++ b/linter-4.2/test_rules/rule49.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 26, + "problem": "LambdaWithTypeParameters", + "suggest": "", + "rule": "Use generic functions instead of generic arrow functions (arkts-no-generic-lambdas)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule5.ts b/linter-4.2/test_rules/rule5.ts new file mode 100644 index 0000000000000000000000000000000000000000..9fbf488e6e590069d879d1c300a45bc8726af165 --- /dev/null +++ b/linter-4.2/test_rules/rule5.ts @@ -0,0 +1,19 @@ + +function f(shouldInitialize: boolean) { + if (shouldInitialize) { + var x = 10 + } + return x +} + +console.log(f(true)) +console.log(f(false)) + +let upper_let = 0 +{ + var scoped_var = 0 + let scoped_let = 0 + upper_let = 5 +} +scoped_var = 5 +scoped_let = 5 \ No newline at end of file diff --git a/linter-4.2/test_rules/rule5.ts.autofix.json b/linter-4.2/test_rules/rule5.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..a69b62867c876703c58f59bc269f8971e43ddd1e --- /dev/null +++ b/linter-4.2/test_rules/rule5.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 4, + "column": 8, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 14, + "column": 5, + "problem": "VarDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 6, + "column": 12, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Variable 'x' is used before being assigned.", + "rule": "Variable 'x' is used before being assigned." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule5.ts.relax.json b/linter-4.2/test_rules/rule5.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..a6b40a08692f10292ebcdb460855a17c9931cdb2 --- /dev/null +++ b/linter-4.2/test_rules/rule5.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 6, + "column": 12, + "problem": "StrictDiagnostic", + "suggest": "Variable 'x' is used before being assigned.", + "rule": "Variable 'x' is used before being assigned." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule5.ts.strict.json b/linter-4.2/test_rules/rule5.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..a2203b7f4de8d749884a2ae5bde7e9f35cfc36a5 --- /dev/null +++ b/linter-4.2/test_rules/rule5.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 4, + "column": 8, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 14, + "column": 5, + "problem": "VarDeclaration", + "suggest": "", + "rule": "Use \"let\" instead of \"var\" (arkts-no-var)" + }, + { + "line": 6, + "column": 12, + "problem": "StrictDiagnostic", + "suggest": "Variable 'x' is used before being assigned.", + "rule": "Variable 'x' is used before being assigned." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule50.ts b/linter-4.2/test_rules/rule50.ts new file mode 100644 index 0000000000000000000000000000000000000000..0fc8c5effee10dca6d6209570480784ae277fdc3 --- /dev/null +++ b/linter-4.2/test_rules/rule50.ts @@ -0,0 +1,11 @@ +const Rectangle = class { + constructor(height: number, width: number) { + this.heigth = height + this.width = width + } + + heigth + width +} + +const rectangle = new Rectangle(0.0, 0.0) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule50.ts.autofix.json b/linter-4.2/test_rules/rule50.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..11e00482c12df95027b597b3993e7bc2ba6528ac --- /dev/null +++ b/linter-4.2/test_rules/rule50.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 1, + "column": 19, + "problem": "ClassExpression", + "autofixable": false, + "suggest": "", + "rule": "Class literals are not supported (arkts-no-class-literals)" + }, + { + "line": 7, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 8, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule50.ts.relax.json b/linter-4.2/test_rules/rule50.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..3c9a8d5ce66717c499c99997d01f6482f957748b --- /dev/null +++ b/linter-4.2/test_rules/rule50.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 7, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 8, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule50.ts.strict.json b/linter-4.2/test_rules/rule50.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..5a3910d4dc00e1c69704851e5beb7a46bcd13a6b --- /dev/null +++ b/linter-4.2/test_rules/rule50.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 19, + "problem": "ClassExpression", + "suggest": "", + "rule": "Class literals are not supported (arkts-no-class-literals)" + }, + { + "line": 7, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 8, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule51.ts b/linter-4.2/test_rules/rule51.ts new file mode 100644 index 0000000000000000000000000000000000000000..6142f7bacda32ddbe9302f0333038174dc23f4ed --- /dev/null +++ b/linter-4.2/test_rules/rule51.ts @@ -0,0 +1,15 @@ +class C { + foo() {} + } + + class C1 implements C { + foo() {} + } + + interface D { + foo(): void + } + + class D1 implements D { + foo() {} + } \ No newline at end of file diff --git a/linter-4.2/test_rules/rule51.ts.autofix.json b/linter-4.2/test_rules/rule51.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..4e0265c93b384dfaa57488da2f87b54e8118e0cb --- /dev/null +++ b/linter-4.2/test_rules/rule51.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 5, + "column": 23, + "problem": "ImplementsClass", + "autofixable": false, + "suggest": "", + "rule": "Classes cannot be specified in \"implements\" clause (arkts-implements-only-iface)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule51.ts.relax.json b/linter-4.2/test_rules/rule51.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..f430157120a02ff4d485a93750776711caf985b7 --- /dev/null +++ b/linter-4.2/test_rules/rule51.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 23, + "problem": "ImplementsClass", + "suggest": "", + "rule": "Classes cannot be specified in \"implements\" clause (arkts-implements-only-iface)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule51.ts.strict.json b/linter-4.2/test_rules/rule51.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..f430157120a02ff4d485a93750776711caf985b7 --- /dev/null +++ b/linter-4.2/test_rules/rule51.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 5, + "column": 23, + "problem": "ImplementsClass", + "suggest": "", + "rule": "Classes cannot be specified in \"implements\" clause (arkts-implements-only-iface)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule52.ts b/linter-4.2/test_rules/rule52.ts new file mode 100644 index 0000000000000000000000000000000000000000..de9a15cd14f3fd8f2bf0ad38ef537c27a11b4005 --- /dev/null +++ b/linter-4.2/test_rules/rule52.ts @@ -0,0 +1,20 @@ +let person = {name: "Bob", isEmployee: true} + +let n = person["name"] +let e = person["isEmployee"] +let s = person["office"] + + +class Person { + constructor(name: string, isEmployee: boolean) { + this.name = name + this.isEmployee = isEmployee + } + + name: string + isEmployee: boolean +} + +let person2 = new Person("Bob", true) +let n1 = person2.name +let e1 = person2.isEmployee \ No newline at end of file diff --git a/linter-4.2/test_rules/rule52.ts.autofix.json b/linter-4.2/test_rules/rule52.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..d08778c7501b273c17067d79c05b867059b61441 --- /dev/null +++ b/linter-4.2/test_rules/rule52.ts.autofix.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": 1, + "column": 14, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 3, + "column": 9, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 4, + "column": 9, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 5, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 9, + "problem": "PropertyAccessByIndex", + "autofixable": true, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule52.ts.relax.json b/linter-4.2/test_rules/rule52.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..0932833876c7cbbc0052ffea4bd92d65b635445b --- /dev/null +++ b/linter-4.2/test_rules/rule52.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 5, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule52.ts.strict.json b/linter-4.2/test_rules/rule52.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..7dead8d48ec6ed395b2e0b8225e3a3b6f2626ac1 --- /dev/null +++ b/linter-4.2/test_rules/rule52.ts.strict.json @@ -0,0 +1,39 @@ +{ + "nodes": [ + { + "line": 1, + "column": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 3, + "column": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 4, + "column": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + }, + { + "line": 5, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 9, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule53.ts b/linter-4.2/test_rules/rule53.ts new file mode 100644 index 0000000000000000000000000000000000000000..96584021242a7c96f6b71c1167ab994989f8a042 --- /dev/null +++ b/linter-4.2/test_rules/rule53.ts @@ -0,0 +1,24 @@ +class Shape {} +class Circle extends Shape {x: number = 5} +class Square extends Shape {y: string = "a"} + +function createShape(): Shape { + return new Circle() +} + +let c1 = createShape() + +let c2 = createShape() as Circle + +// No report is provided during compilation +// nor during runtime if cast is wrong: +let c3 = createShape() as Square +console.log(c3.y) // undefined + +// Important corner case for casting primitives to the boxed counterparts: +// The left operand is not properly boxed here in in runtime +// because "as" has no runtime effect in TypeScript +let e1 = (5.0 as Number) instanceof Number // false + +// Number object is created and instanceof works as expected: +let e2 = (new Number(5.0)) instanceof Number // true \ No newline at end of file diff --git a/linter-4.2/test_rules/rule53.ts.autofix.json b/linter-4.2/test_rules/rule53.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..919e0b88f5549281a70b05f2d27d3a241757ba73 --- /dev/null +++ b/linter-4.2/test_rules/rule53.ts.autofix.json @@ -0,0 +1,27 @@ +{ + "nodes": [ + { + "line": 9, + "column": 10, + "problem": "TypeAssertion", + "autofixable": true, + "autofix": [ + { + "start": 172, + "end": 194, + "replacementText": "createShape() as Circle" + } + ], + "suggest": "", + "rule": "Only \"as T\" syntax is supported for type casts (arkts-as-casts)" + }, + { + "line": 21, + "column": 11, + "problem": "TypeAssertion", + "autofixable": false, + "suggest": "", + "rule": "Only \"as T\" syntax is supported for type casts (arkts-as-casts)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule53.ts.relax.json b/linter-4.2/test_rules/rule53.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule53.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule53.ts.strict.json b/linter-4.2/test_rules/rule53.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..41e73c7bede0b811f7dee5ed482211923d0fc1ad --- /dev/null +++ b/linter-4.2/test_rules/rule53.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 9, + "column": 10, + "problem": "TypeAssertion", + "suggest": "", + "rule": "Only \"as T\" syntax is supported for type casts (arkts-as-casts)" + }, + { + "line": 21, + "column": 11, + "problem": "TypeAssertion", + "suggest": "", + "rule": "Only \"as T\" syntax is supported for type casts (arkts-as-casts)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule55.ts b/linter-4.2/test_rules/rule55.ts new file mode 100644 index 0000000000000000000000000000000000000000..fabc84096dfd9ffb436a458cb77aaca29d534a58 --- /dev/null +++ b/linter-4.2/test_rules/rule55.ts @@ -0,0 +1,18 @@ +let a = +5 // 5 as number +let b = +"5" // 5 as number +let c = -5 // -5 as number +let d = -"5" // -5 as number +let e = ~5 // -6 as number +let f = ~"5" // -6 as number +let g = +"string" // NaN as number + +function returnTen(): string { + return "-10" +} + +function returnString(): string { + return "string" +} + +let x = +returnTen() // -10 as number +let y = +returnString() // NaN \ No newline at end of file diff --git a/linter-4.2/test_rules/rule55.ts.autofix.json b/linter-4.2/test_rules/rule55.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c91114f5ecf4522d0631f517ab03675c2e38dfa5 --- /dev/null +++ b/linter-4.2/test_rules/rule55.ts.autofix.json @@ -0,0 +1,52 @@ +{ + "nodes": [ + { + "line": 2, + "column": 9, + "problem": "UnaryArithmNotNumber", + "autofixable": false, + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 4, + "column": 9, + "problem": "UnaryArithmNotNumber", + "autofixable": false, + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 6, + "column": 9, + "problem": "UnaryArithmNotNumber", + "autofixable": false, + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 7, + "column": 9, + "problem": "UnaryArithmNotNumber", + "autofixable": false, + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 17, + "column": 9, + "problem": "UnaryArithmNotNumber", + "autofixable": false, + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 18, + "column": 9, + "problem": "UnaryArithmNotNumber", + "autofixable": false, + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule55.ts.relax.json b/linter-4.2/test_rules/rule55.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..cdb3b3b696e1275750bdddd6f7778f8b810594a3 --- /dev/null +++ b/linter-4.2/test_rules/rule55.ts.relax.json @@ -0,0 +1,46 @@ +{ + "nodes": [ + { + "line": 2, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 4, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 6, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 7, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 17, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 18, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule55.ts.strict.json b/linter-4.2/test_rules/rule55.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..cdb3b3b696e1275750bdddd6f7778f8b810594a3 --- /dev/null +++ b/linter-4.2/test_rules/rule55.ts.strict.json @@ -0,0 +1,46 @@ +{ + "nodes": [ + { + "line": 2, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 4, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 6, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 7, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 17, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + }, + { + "line": 18, + "column": 9, + "problem": "UnaryArithmNotNumber", + "suggest": "", + "rule": "Unary operators \"+\", \"-\" and \"~\" work only on numbers (arkts-no-polymorphic-unops)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule59.ts b/linter-4.2/test_rules/rule59.ts new file mode 100644 index 0000000000000000000000000000000000000000..97150733a8ed59338547e1608866aad878ffb80f --- /dev/null +++ b/linter-4.2/test_rules/rule59.ts @@ -0,0 +1,15 @@ +class Point { + x?: number = 0.0 + y?: number = 0.0 +} + +let p = new Point() +delete p.y + +class Point2 { + x: number | null = 0 + y: number | null = 0 +} + +let p2 = new Point() +p2.y = null \ No newline at end of file diff --git a/linter-4.2/test_rules/rule59.ts.autofix.json b/linter-4.2/test_rules/rule59.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c7b064b9f8fadf48f6dd5f4ecf7ab0493a21ab8f --- /dev/null +++ b/linter-4.2/test_rules/rule59.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 7, + "column": 1, + "problem": "DeleteOperator", + "autofixable": false, + "suggest": "", + "rule": "\"delete\" operator is not supported (arkts-no-delete)" + }, + { + "line": 15, + "column": 1, + "problem": "StrictDiagnostic", + "autofixable": false, + "suggest": "Type 'null' is not assignable to type 'number | undefined'.", + "rule": "Type 'null' is not assignable to type 'number | undefined'." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule59.ts.relax.json b/linter-4.2/test_rules/rule59.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..63b79f7f03b16abbdbfabceac47acd11459cd055 --- /dev/null +++ b/linter-4.2/test_rules/rule59.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 7, + "column": 1, + "problem": "DeleteOperator", + "suggest": "", + "rule": "\"delete\" operator is not supported (arkts-no-delete)" + }, + { + "line": 15, + "column": 1, + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number | undefined'.", + "rule": "Type 'null' is not assignable to type 'number | undefined'." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule59.ts.strict.json b/linter-4.2/test_rules/rule59.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..63b79f7f03b16abbdbfabceac47acd11459cd055 --- /dev/null +++ b/linter-4.2/test_rules/rule59.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 7, + "column": 1, + "problem": "DeleteOperator", + "suggest": "", + "rule": "\"delete\" operator is not supported (arkts-no-delete)" + }, + { + "line": 15, + "column": 1, + "problem": "StrictDiagnostic", + "suggest": "Type 'null' is not assignable to type 'number | undefined'.", + "rule": "Type 'null' is not assignable to type 'number | undefined'." + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule60.ts b/linter-4.2/test_rules/rule60.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffc67284ca32dd9835c5ec80f1285b0290daa011 --- /dev/null +++ b/linter-4.2/test_rules/rule60.ts @@ -0,0 +1,13 @@ +let n1 = 42 +let s1 = "foo" +console.log(typeof n1) // "number" +console.log(typeof s1) // "string" +let n2: typeof n1 +let s2: typeof s1 + +let n3 = 42 +let s3 = "foo" +console.log(typeof n3) // "number" +console.log(typeof s3) // "string" +let n4: number +let s4: string \ No newline at end of file diff --git a/linter-4.2/test_rules/rule60.ts.autofix.json b/linter-4.2/test_rules/rule60.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..a1e116149489e6c61a7c5d75d7947da000c6e29f --- /dev/null +++ b/linter-4.2/test_rules/rule60.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 5, + "column": 9, + "problem": "TypeQuery", + "autofixable": false, + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 6, + "column": 9, + "problem": "TypeQuery", + "autofixable": false, + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule60.ts.relax.json b/linter-4.2/test_rules/rule60.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..4b4c06934fa64f36a8a6e8ab2ebe22d21dcf491c --- /dev/null +++ b/linter-4.2/test_rules/rule60.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 5, + "column": 9, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 6, + "column": 9, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule60.ts.strict.json b/linter-4.2/test_rules/rule60.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..4b4c06934fa64f36a8a6e8ab2ebe22d21dcf491c --- /dev/null +++ b/linter-4.2/test_rules/rule60.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 5, + "column": 9, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + }, + { + "line": 6, + "column": 9, + "problem": "TypeQuery", + "suggest": "", + "rule": "\"typeof\" operator is allowed only in expression contexts (arkts-no-type-query)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule63.ts b/linter-4.2/test_rules/rule63.ts new file mode 100644 index 0000000000000000000000000000000000000000..892bd7189b3643161042997f87a8414088be1e05 --- /dev/null +++ b/linter-4.2/test_rules/rule63.ts @@ -0,0 +1,15 @@ +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-4.2/test_rules/rule63.ts.autofix.json b/linter-4.2/test_rules/rule63.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c7b928233d39252bea33c1fb165d5886b208b718 --- /dev/null +++ b/linter-4.2/test_rules/rule63.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "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-4.2/test_rules/rule63.ts.relax.json b/linter-4.2/test_rules/rule63.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..324172c396efb371cf19b611133ebd51c040aa0e --- /dev/null +++ b/linter-4.2/test_rules/rule63.ts.relax.json @@ -0,0 +1,25 @@ +{ + "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-4.2/test_rules/rule63.ts.strict.json b/linter-4.2/test_rules/rule63.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..324172c396efb371cf19b611133ebd51c040aa0e --- /dev/null +++ b/linter-4.2/test_rules/rule63.ts.strict.json @@ -0,0 +1,25 @@ +{ + "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-4.2/test_rules/rule65.ts b/linter-4.2/test_rules/rule65.ts new file mode 100644 index 0000000000000000000000000000000000000000..d4d849f76c135678ea2c74c7e420c408d75976ed --- /dev/null +++ b/linter-4.2/test_rules/rule65.ts @@ -0,0 +1,9 @@ +class X { + // ... +} + +let a = (new X()) instanceof Object // true +let b = (new X()) instanceof X // true + +let c = X instanceof Object // true, left operand is a type +let d = X instanceof X // false, left operand is a type \ No newline at end of file diff --git a/linter-4.2/test_rules/rule65.ts.autofix.json b/linter-4.2/test_rules/rule65.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..9e70ad4de09a61930f428ca3ac85c7d068e08d55 --- /dev/null +++ b/linter-4.2/test_rules/rule65.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 8, + "column": 9, + "problem": "InstanceofUnsupported", + "autofixable": false, + "suggest": "", + "rule": "\"instanceof\" operator is partially supported (arkts-instanceof-ref-types)" + }, + { + "line": 9, + "column": 9, + "problem": "InstanceofUnsupported", + "autofixable": false, + "suggest": "", + "rule": "\"instanceof\" operator is partially supported (arkts-instanceof-ref-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule65.ts.relax.json b/linter-4.2/test_rules/rule65.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..050b37b6892e06316f492c677fe4711892ab647d --- /dev/null +++ b/linter-4.2/test_rules/rule65.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 8, + "column": 9, + "problem": "InstanceofUnsupported", + "suggest": "", + "rule": "\"instanceof\" operator is partially supported (arkts-instanceof-ref-types)" + }, + { + "line": 9, + "column": 9, + "problem": "InstanceofUnsupported", + "suggest": "", + "rule": "\"instanceof\" operator is partially supported (arkts-instanceof-ref-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule65.ts.strict.json b/linter-4.2/test_rules/rule65.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..050b37b6892e06316f492c677fe4711892ab647d --- /dev/null +++ b/linter-4.2/test_rules/rule65.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 8, + "column": 9, + "problem": "InstanceofUnsupported", + "suggest": "", + "rule": "\"instanceof\" operator is partially supported (arkts-instanceof-ref-types)" + }, + { + "line": 9, + "column": 9, + "problem": "InstanceofUnsupported", + "suggest": "", + "rule": "\"instanceof\" operator is partially supported (arkts-instanceof-ref-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule66.ts b/linter-4.2/test_rules/rule66.ts new file mode 100644 index 0000000000000000000000000000000000000000..b301c85fc956e15b7ca577d88fcf3b81cbbe297c --- /dev/null +++ b/linter-4.2/test_rules/rule66.ts @@ -0,0 +1,8 @@ +class Person { + name: string = "" +} +let p = new Person() + +let b = "name" in p + +let c = p instanceof Person \ No newline at end of file diff --git a/linter-4.2/test_rules/rule66.ts.autofix.json b/linter-4.2/test_rules/rule66.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..369960bded74ce8510cb6e04ec80949e9cee8c86 --- /dev/null +++ b/linter-4.2/test_rules/rule66.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 6, + "column": 16, + "problem": "InOperator", + "autofixable": false, + "suggest": "", + "rule": "\"in\" operator is not supported (arkts-no-in)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule66.ts.relax.json b/linter-4.2/test_rules/rule66.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..301f381a1b199aace7c429e45fb7a3b7a1c32bb8 --- /dev/null +++ b/linter-4.2/test_rules/rule66.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 6, + "column": 16, + "problem": "InOperator", + "suggest": "", + "rule": "\"in\" operator is not supported (arkts-no-in)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule66.ts.strict.json b/linter-4.2/test_rules/rule66.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..301f381a1b199aace7c429e45fb7a3b7a1c32bb8 --- /dev/null +++ b/linter-4.2/test_rules/rule66.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 6, + "column": 16, + "problem": "InOperator", + "suggest": "", + "rule": "\"in\" operator is not supported (arkts-no-in)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule69.ts b/linter-4.2/test_rules/rule69.ts new file mode 100644 index 0000000000000000000000000000000000000000..c61eee0cb6ccb8c16fc09a6312bd2f86a3f9da5b --- /dev/null +++ b/linter-4.2/test_rules/rule69.ts @@ -0,0 +1,20 @@ +let [one, two] = [1, 2]; +[one, two] = [two, one] + +let head, tail +[head, ...tail] = [1, 2, 3, 4] + +let arr2: number[] = [1, 2] +let one2 = arr2[0] +let two2 = arr2[1] + +let tmp = one +one = two +two = tmp + +let data2: Number[] = [1, 2, 3, 4] +let head2 = data2[0] +let tail2: Number[] = [] +for (let i = 1; i < data2.length; ++i) { + tail.push(data2[i]) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule69.ts.autofix.json b/linter-4.2/test_rules/rule69.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..0c8f1f91d0f533625f3f90f90c8e26bb254ba9f5 --- /dev/null +++ b/linter-4.2/test_rules/rule69.ts.autofix.json @@ -0,0 +1,52 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "DestructuringDeclaration", + "autofixable": false, + "suggest": "", + "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)" + }, + { + "line": 2, + "column": 1, + "problem": "DestructuringAssignment", + "autofixable": false, + "suggest": "", + "rule": "Destructuring assignment is not supported (arkts-no-destruct-assignment)" + }, + { + "line": 4, + "column": 5, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 4, + "column": 11, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 1, + "problem": "DestructuringAssignment", + "autofixable": false, + "suggest": "", + "rule": "Destructuring assignment is not supported (arkts-no-destruct-assignment)" + }, + { + "line": 5, + "column": 8, + "problem": "SpreadOperator", + "autofixable": false, + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule69.ts.relax.json b/linter-4.2/test_rules/rule69.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..740d7e2ea0f467d656ea296acf68136f61cf483a --- /dev/null +++ b/linter-4.2/test_rules/rule69.ts.relax.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 4, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 4, + "column": 11, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 8, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule69.ts.strict.json b/linter-4.2/test_rules/rule69.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..d09d39688d644d94b43a277ee72b9c66553f0ed9 --- /dev/null +++ b/linter-4.2/test_rules/rule69.ts.strict.json @@ -0,0 +1,46 @@ +{ + "nodes": [ + { + "line": 1, + "column": 5, + "problem": "DestructuringDeclaration", + "suggest": "", + "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)" + }, + { + "line": 2, + "column": 1, + "problem": "DestructuringAssignment", + "suggest": "", + "rule": "Destructuring assignment is not supported (arkts-no-destruct-assignment)" + }, + { + "line": 4, + "column": 5, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 4, + "column": 11, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 5, + "column": 1, + "problem": "DestructuringAssignment", + "suggest": "", + "rule": "Destructuring assignment is not supported (arkts-no-destruct-assignment)" + }, + { + "line": 5, + "column": 8, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule71.ts b/linter-4.2/test_rules/rule71.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f9078b6394cfd5c61fc79490bd48be3436bb484 --- /dev/null +++ b/linter-4.2/test_rules/rule71.ts @@ -0,0 +1,16 @@ +for (let i = 0, j = 0; i < 10; ++i, j += 2) { + console.log(i) + console.log(j) +} + +let x = 0 +x = (++x, x++) + +for (let i = 0, j = 0; i < 10; ++i, j += 2) { + console.log(i) + console.log(j) +} + +let x2 = 0 +++x2 +x2 = x2++ \ No newline at end of file diff --git a/linter-4.2/test_rules/rule71.ts.autofix.json b/linter-4.2/test_rules/rule71.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..0fb0c8f20fa29539d1be8cf6ad1f1596e4cc22b0 --- /dev/null +++ b/linter-4.2/test_rules/rule71.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 7, + "column": 6, + "problem": "CommaOperator", + "autofixable": false, + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule71.ts.relax.json b/linter-4.2/test_rules/rule71.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..8cc404d64a937c581d8e5839cd39f46f542c401a --- /dev/null +++ b/linter-4.2/test_rules/rule71.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 7, + "column": 6, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule71.ts.strict.json b/linter-4.2/test_rules/rule71.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..8cc404d64a937c581d8e5839cd39f46f542c401a --- /dev/null +++ b/linter-4.2/test_rules/rule71.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 7, + "column": 6, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule74.ts b/linter-4.2/test_rules/rule74.ts new file mode 100644 index 0000000000000000000000000000000000000000..63df75da4006c0d2f93b3309cac3bcb8ab37dbee --- /dev/null +++ b/linter-4.2/test_rules/rule74.ts @@ -0,0 +1,20 @@ +class Point { + x: number = 0.0 + y: number = 0.0 +} + +function returnZeroPoint(): Point { + return new Point() +} + +let {x, y} = returnZeroPoint() + + + +function returnZeroPoint2(): Point { + return new Point() +} + +let zp = returnZeroPoint2() +let x2 = zp.x +let y2 = zp.y \ No newline at end of file diff --git a/linter-4.2/test_rules/rule74.ts.autofix.json b/linter-4.2/test_rules/rule74.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..83a853b0a700b0f85e511e1bf61e16f7e43f11e3 --- /dev/null +++ b/linter-4.2/test_rules/rule74.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 10, + "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-4.2/test_rules/rule74.ts.relax.json b/linter-4.2/test_rules/rule74.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule74.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule74.ts.strict.json b/linter-4.2/test_rules/rule74.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..53af79469decb8522de829911ec4a576ef08d366 --- /dev/null +++ b/linter-4.2/test_rules/rule74.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 10, + "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-4.2/test_rules/rule76.ts b/linter-4.2/test_rules/rule76.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0913cbd2fda4d223f3dec555eb29247f59352e7 --- /dev/null +++ b/linter-4.2/test_rules/rule76.ts @@ -0,0 +1,10 @@ +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-4.2/test_rules/rule76.ts.autofix.json b/linter-4.2/test_rules/rule76.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..84c9ce9886d6d149595a468b219222e39af37a6b --- /dev/null +++ b/linter-4.2/test_rules/rule76.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "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-4.2/test_rules/rule76.ts.relax.json b/linter-4.2/test_rules/rule76.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule76.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule76.ts.strict.json b/linter-4.2/test_rules/rule76.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..50913e605d6420f5cf315ebbbdbd23763d79ef04 --- /dev/null +++ b/linter-4.2/test_rules/rule76.ts.strict.json @@ -0,0 +1,11 @@ +{ + "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-4.2/test_rules/rule79.ts b/linter-4.2/test_rules/rule79.ts new file mode 100644 index 0000000000000000000000000000000000000000..0c35b2e6376ae370faaab7dd4d1132a2c914fcc3 --- /dev/null +++ b/linter-4.2/test_rules/rule79.ts @@ -0,0 +1,14 @@ +try { + // some code +} +catch (a: unknown) { + // handle error +} + + +try { + // some code +} +catch (a) { + // handle error +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule79.ts.autofix.json b/linter-4.2/test_rules/rule79.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..109518d2aea66e3bb416d2451f2c2ebe0a2b1450 --- /dev/null +++ b/linter-4.2/test_rules/rule79.ts.autofix.json @@ -0,0 +1,27 @@ +{ + "nodes": [ + { + "line": 4, + "column": 1, + "problem": "CatchWithUnsupportedType", + "autofixable": true, + "autofix": [ + { + "start": 32, + "end": 42, + "replacementText": "a" + } + ], + "suggest": "", + "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)" + }, + { + "line": 4, + "column": 11, + "problem": "UnknownType", + "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-4.2/test_rules/rule79.ts.relax.json b/linter-4.2/test_rules/rule79.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..fbfdd7e19e23a624dd3e1713b131567fa191b81b --- /dev/null +++ b/linter-4.2/test_rules/rule79.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 4, + "column": 11, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule79.ts.strict.json b/linter-4.2/test_rules/rule79.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..486dbc46a504eee3152cbf56c5ea4fd8d8d4b720 --- /dev/null +++ b/linter-4.2/test_rules/rule79.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 4, + "column": 1, + "problem": "CatchWithUnsupportedType", + "suggest": "", + "rule": "Type annotation in catch clause is not supported (arkts-no-types-in-catch)" + }, + { + "line": 4, + "column": 11, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule8.ts b/linter-4.2/test_rules/rule8.ts new file mode 100644 index 0000000000000000000000000000000000000000..599044e697099365eb73f19b01c16efeba52f503 --- /dev/null +++ b/linter-4.2/test_rules/rule8.ts @@ -0,0 +1,13 @@ + +let value1 : any +value1 = true +value1 = 42 + +let value2 : unknown +value2 = true +value2 = 42 + +let value_b: boolean = true // OR: let value_b = true +let value_n: number = 42 // OR: let value_n = 42 +let value_o1: Object = true +let value_o2: Object = 42 \ No newline at end of file diff --git a/linter-4.2/test_rules/rule8.ts.autofix.json b/linter-4.2/test_rules/rule8.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..7bd209b8b9764e186890fbe4b2b677a6d4dfee78 --- /dev/null +++ b/linter-4.2/test_rules/rule8.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 2, + "column": 14, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 6, + "column": 14, + "problem": "UnknownType", + "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-4.2/test_rules/rule8.ts.relax.json b/linter-4.2/test_rules/rule8.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..742ecfb7fbbb19ae47c2ec92fd4defb9ca8f05f8 --- /dev/null +++ b/linter-4.2/test_rules/rule8.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 6, + "column": 14, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule8.ts.strict.json b/linter-4.2/test_rules/rule8.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..742ecfb7fbbb19ae47c2ec92fd4defb9ca8f05f8 --- /dev/null +++ b/linter-4.2/test_rules/rule8.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 6, + "column": 14, + "problem": "UnknownType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule80.ts b/linter-4.2/test_rules/rule80.ts new file mode 100644 index 0000000000000000000000000000000000000000..6385a091a18ef291588cac4d3cf1fa456be391b6 --- /dev/null +++ b/linter-4.2/test_rules/rule80.ts @@ -0,0 +1,10 @@ +let a: number[] = [1.0, 2.0, 3.0] +for (let i in a) { + console.log(a[i]) +} + + +let a2: number[] = [1.0, 2.0, 3.0] +for (let i = 0; i < a2.length; ++i) { + console.log(a[i]) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule80.ts.autofix.json b/linter-4.2/test_rules/rule80.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..54c46bffca3fc08f3f6cb04db8809034ecd95272 --- /dev/null +++ b/linter-4.2/test_rules/rule80.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "ForInStatement", + "autofixable": false, + "suggest": "", + "rule": "\"for .. in\" is not supported (arkts-no-for-in)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule80.ts.relax.json b/linter-4.2/test_rules/rule80.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..6eaffeec5e7386cc3f3bf9efa4dc3ab76aabed41 --- /dev/null +++ b/linter-4.2/test_rules/rule80.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "ForInStatement", + "suggest": "", + "rule": "\"for .. in\" is not supported (arkts-no-for-in)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule80.ts.strict.json b/linter-4.2/test_rules/rule80.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..6eaffeec5e7386cc3f3bf9efa4dc3ab76aabed41 --- /dev/null +++ b/linter-4.2/test_rules/rule80.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "ForInStatement", + "suggest": "", + "rule": "\"for .. in\" is not supported (arkts-no-for-in)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule82.ts b/linter-4.2/test_rules/rule82.ts new file mode 100644 index 0000000000000000000000000000000000000000..597aa69cbd62031d55d60cd525a0f59d5f33120f --- /dev/null +++ b/linter-4.2/test_rules/rule82.ts @@ -0,0 +1,9 @@ +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-4.2/test_rules/rule82.ts.autofix.json b/linter-4.2/test_rules/rule82.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..aa47fe476cb1a9f1b0c521dfc3cf00745633647c --- /dev/null +++ b/linter-4.2/test_rules/rule82.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "ForOfNonArray", + "autofixable": false, + "suggest": "", + "rule": "\"for-of\" is supported only for arrays and strings (arkts-for-of-str-arr)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule82.ts.relax.json b/linter-4.2/test_rules/rule82.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule82.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule82.ts.strict.json b/linter-4.2/test_rules/rule82.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..a01df14e18fdc3a31a3ac71ec5936087291cb477 --- /dev/null +++ b/linter-4.2/test_rules/rule82.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 1, + "problem": "ForOfNonArray", + "suggest": "", + "rule": "\"for-of\" is supported only for arrays and strings (arkts-for-of-str-arr)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule83.ts b/linter-4.2/test_rules/rule83.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ac377bfc58b754a47722e19e78f48584ab13bd2 --- /dev/null +++ b/linter-4.2/test_rules/rule83.ts @@ -0,0 +1,13 @@ +type OptionsFlags = { + [Property in keyof Type]: boolean +} + +class C { + n: number = 0 + s: string = "" +} + +class CFlags { + n: boolean = false + s: boolean = false +} diff --git a/linter-4.2/test_rules/rule83.ts.autofix.json b/linter-4.2/test_rules/rule83.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..5d0cd5d8878de3a550250582915aead18b3c2bff --- /dev/null +++ b/linter-4.2/test_rules/rule83.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 1, + "column": 27, + "problem": "MappedType", + "autofixable": false, + "suggest": "", + "rule": "Mapped type expression is not supported (arkts-no-mapped-types)" + }, + { + "line": 2, + "column": 18, + "problem": "KeyOfOperator", + "autofixable": false, + "suggest": "", + "rule": "\"keyof\" operator is not supported (arkts-no-keyof)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule83.ts.relax.json b/linter-4.2/test_rules/rule83.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..50f8420e91259bbcd4903da3938ce4107d5dd79d --- /dev/null +++ b/linter-4.2/test_rules/rule83.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 27, + "problem": "MappedType", + "suggest": "", + "rule": "Mapped type expression is not supported (arkts-no-mapped-types)" + }, + { + "line": 2, + "column": 18, + "problem": "KeyOfOperator", + "suggest": "", + "rule": "\"keyof\" operator is not supported (arkts-no-keyof)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule83.ts.strict.json b/linter-4.2/test_rules/rule83.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..50f8420e91259bbcd4903da3938ce4107d5dd79d --- /dev/null +++ b/linter-4.2/test_rules/rule83.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 27, + "problem": "MappedType", + "suggest": "", + "rule": "Mapped type expression is not supported (arkts-no-mapped-types)" + }, + { + "line": 2, + "column": 18, + "problem": "KeyOfOperator", + "suggest": "", + "rule": "\"keyof\" operator is not supported (arkts-no-keyof)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule84.ts b/linter-4.2/test_rules/rule84.ts new file mode 100644 index 0000000000000000000000000000000000000000..343706f1be4343fd4de11ad0f2ddf8edcf0732fe --- /dev/null +++ b/linter-4.2/test_rules/rule84.ts @@ -0,0 +1,7 @@ +with (Math) { // Compile-time error, but JavaScript code still emitted + let r: number = 42 + console.log("Area: ", PI * r * r) +} + +let r: number = 42 +console.log("Area: ", Math.PI * r * r) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule84.ts.autofix.json b/linter-4.2/test_rules/rule84.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..cb2a15285aed065e9e0fcf0b444ae9f46259c7a1 --- /dev/null +++ b/linter-4.2/test_rules/rule84.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "WithStatement", + "autofixable": false, + "suggest": "", + "rule": "\"with\" statement is not supported (arkts-no-with)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule84.ts.relax.json b/linter-4.2/test_rules/rule84.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..235ef43d7bbd40fe2ed41ad0bcf807aa7b5c5cb1 --- /dev/null +++ b/linter-4.2/test_rules/rule84.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "WithStatement", + "suggest": "", + "rule": "\"with\" statement is not supported (arkts-no-with)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule84.ts.strict.json b/linter-4.2/test_rules/rule84.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..235ef43d7bbd40fe2ed41ad0bcf807aa7b5c5cb1 --- /dev/null +++ b/linter-4.2/test_rules/rule84.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "WithStatement", + "suggest": "", + "rule": "\"with\" statement is not supported (arkts-no-with)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule87.ts b/linter-4.2/test_rules/rule87.ts new file mode 100644 index 0000000000000000000000000000000000000000..59e4f8229c2f824e06db62e60ce27a97a78483d0 --- /dev/null +++ b/linter-4.2/test_rules/rule87.ts @@ -0,0 +1,3 @@ +throw 4 +throw "" +throw new Error() \ No newline at end of file diff --git a/linter-4.2/test_rules/rule87.ts.autofix.json b/linter-4.2/test_rules/rule87.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..c361e7f53072950574d8d6d6adf8ee29ce282f05 --- /dev/null +++ b/linter-4.2/test_rules/rule87.ts.autofix.json @@ -0,0 +1,34 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ThrowStatement", + "autofixable": true, + "autofix": [ + { + "start": 6, + "end": 7, + "replacementText": "new Error('', 4)" + } + ], + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)" + }, + { + "line": 2, + "column": 1, + "problem": "ThrowStatement", + "autofixable": true, + "autofix": [ + { + "start": 14, + "end": 16, + "replacementText": "new Error(\"\")" + } + ], + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule87.ts.relax.json b/linter-4.2/test_rules/rule87.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule87.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule87.ts.strict.json b/linter-4.2/test_rules/rule87.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..c8b63f39e26182dd551674e01d25d53443920357 --- /dev/null +++ b/linter-4.2/test_rules/rule87.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "ThrowStatement", + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)" + }, + { + "line": 2, + "column": 1, + "problem": "ThrowStatement", + "suggest": "", + "rule": "\"throw\" statements cannot accept values of arbitrary types (arkts-limited-throw)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule90.ts b/linter-4.2/test_rules/rule90.ts new file mode 100644 index 0000000000000000000000000000000000000000..b73bc8f2c5cb3950a492399c94d3f077d5d3d57c --- /dev/null +++ b/linter-4.2/test_rules/rule90.ts @@ -0,0 +1,37 @@ + // Compile-time error with noImplicitAny + function f(x: number) { + if (x <= 0) { + return x + } + return g(x) + } + + // Compile-time error with noImplicitAny + function g(x: number) { + return f(x - 1) + } + + function doOperation(x: number, y: number) { + return x + y + } + + console.log(f(10)) + console.log(doOperation(2, 3)) + + function f1(x: number) : number { + if (x <= 0) { + return x + } + return g1(x) + } + + function g1(x: number) { + return f1(x - 1) + } + + function doOperation1(x: number, y: number) { + return x + y + } + + console.log(f1(10)) + console.log(doOperation1(2, 3)) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule90.ts.autofix.json b/linter-4.2/test_rules/rule90.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..a4cb311ed4b65a0b07b2a947cee0b509f8234c3f --- /dev/null +++ b/linter-4.2/test_rules/rule90.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "LimitedReturnTypeInference", + "autofixable": false, + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + }, + { + "line": 10, + "column": 5, + "problem": "LimitedReturnTypeInference", + "autofixable": false, + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule90.ts.relax.json b/linter-4.2/test_rules/rule90.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule90.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule90.ts.strict.json b/linter-4.2/test_rules/rule90.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..5210923dec7884d624e4baea605d05f3f534408e --- /dev/null +++ b/linter-4.2/test_rules/rule90.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + }, + { + "line": 10, + "column": 5, + "problem": "LimitedReturnTypeInference", + "suggest": "", + "rule": "Function return type inference is limited (arkts-no-implicit-return-types)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule91.ts b/linter-4.2/test_rules/rule91.ts new file mode 100644 index 0000000000000000000000000000000000000000..6fb94a78715136f7f5cb4b4497ff34a22c0cac2e --- /dev/null +++ b/linter-4.2/test_rules/rule91.ts @@ -0,0 +1,22 @@ +function drawText({ text = "", location: [x, y] = [0, 0], bold = false }) { + console.log(text) + console.log(x) + console.log(y) + console.log(bold) +} + +drawText({ text: "Hello, world!", location: [100, 50], bold: true }) + + +function drawText1(text: String, location: number[], bold: boolean) { + let x = location[0] + let y = location[1] + console.log(text) + console.log(x) + console.log(y) + console.log(bold) +} + +function main() { + drawText1("Hello, world!", [100, 50], true) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule91.ts.autofix.json b/linter-4.2/test_rules/rule91.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..5d1531ea7804eda865cb85f00f5449a98168be40 --- /dev/null +++ b/linter-4.2/test_rules/rule91.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 1, + "column": 19, + "problem": "DestructuringParameter", + "autofixable": false, + "suggest": "", + "rule": "Destructuring parameter declarations are not supported (arkts-no-destruct-params)" + }, + { + "line": 8, + "column": 10, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "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-4.2/test_rules/rule91.ts.relax.json b/linter-4.2/test_rules/rule91.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..f0f7ff98904a48e3a305b006402fc1639acdea3f --- /dev/null +++ b/linter-4.2/test_rules/rule91.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 19, + "problem": "DestructuringParameter", + "suggest": "", + "rule": "Destructuring parameter declarations are not supported (arkts-no-destruct-params)" + }, + { + "line": 8, + "column": 10, + "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-4.2/test_rules/rule91.ts.strict.json b/linter-4.2/test_rules/rule91.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..f0f7ff98904a48e3a305b006402fc1639acdea3f --- /dev/null +++ b/linter-4.2/test_rules/rule91.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 19, + "problem": "DestructuringParameter", + "suggest": "", + "rule": "Destructuring parameter declarations are not supported (arkts-no-destruct-params)" + }, + { + "line": 8, + "column": 10, + "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-4.2/test_rules/rule92.ts b/linter-4.2/test_rules/rule92.ts new file mode 100644 index 0000000000000000000000000000000000000000..24d92acfc128f48fc3711abed73f7657375fffdb --- /dev/null +++ b/linter-4.2/test_rules/rule92.ts @@ -0,0 +1,21 @@ +function addNum(a: number, b: number): void { + function logToConsole(message: String): void { + console.log(message) + } + + let result = a + b + + logToConsole("result is " + result) +} + + +function addNum2(a: number, b: number): void { + // Use lambda instead of a nested function: + let logToConsole: (message: string) => void = (message: string): void => { + console.log(message) + } + + let result = a + b + + logToConsole("result is " + result) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule92.ts.autofix.json b/linter-4.2/test_rules/rule92.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..e19730492416e0d906c67456a0b853d8bb8b9e1f --- /dev/null +++ b/linter-4.2/test_rules/rule92.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "LocalFunction", + "autofixable": false, + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule92.ts.relax.json b/linter-4.2/test_rules/rule92.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..13f13363f579325755e8954b4011963971667481 --- /dev/null +++ b/linter-4.2/test_rules/rule92.ts.relax.json @@ -0,0 +1,3 @@ +{ + "nodes": [] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule92.ts.strict.json b/linter-4.2/test_rules/rule92.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..f63a413163ac0a18290469140e4ce06b57dcd75d --- /dev/null +++ b/linter-4.2/test_rules/rule92.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 2, + "column": 5, + "problem": "LocalFunction", + "suggest": "", + "rule": "Nested functions are not supported (arkts-no-nested-funcs)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule93.ts b/linter-4.2/test_rules/rule93.ts new file mode 100644 index 0000000000000000000000000000000000000000..76703f201f66ab35bee24c42ba6e2075c8ada311 --- /dev/null +++ b/linter-4.2/test_rules/rule93.ts @@ -0,0 +1,27 @@ +function foo(i: number) { + this.count = i // Compile-time error only with noImplicitThis +} + +class A { + count: number = 1 + m = foo +} + +let a = new A() +console.log(a.count) // prints "1" +a.m(2) +console.log(a.count) // prints "2" + +class A1 { + count: number = 1 + m(i: number): void { + this.count = i + } +} + +function main(): void { + let a = new A1() + console.log(a.count) // prints "1" + a.m(2) + console.log(a.count) // prints "2" +} diff --git a/linter-4.2/test_rules/rule93.ts.autofix.json b/linter-4.2/test_rules/rule93.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..872acd394066cbc9e387b56a855037bb74ddc8ab --- /dev/null +++ b/linter-4.2/test_rules/rule93.ts.autofix.json @@ -0,0 +1,12 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "FunctionContainsThis", + "autofixable": false, + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule93.ts.relax.json b/linter-4.2/test_rules/rule93.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..a16283a186b51f9545d9a78a95a673bbd7acbd15 --- /dev/null +++ b/linter-4.2/test_rules/rule93.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule93.ts.strict.json b/linter-4.2/test_rules/rule93.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..a16283a186b51f9545d9a78a95a673bbd7acbd15 --- /dev/null +++ b/linter-4.2/test_rules/rule93.ts.strict.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "FunctionContainsThis", + "suggest": "", + "rule": "Using \"this\" inside stand-alone functions is not supported (arkts-no-standalone-this)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule94.ts b/linter-4.2/test_rules/rule94.ts new file mode 100644 index 0000000000000000000000000000000000000000..970288c1085b2779f8294f61a970f16abe05f186 --- /dev/null +++ b/linter-4.2/test_rules/rule94.ts @@ -0,0 +1,22 @@ +function* counter(start: number, end: number) { + for (let i = start; i <= end; i++) { + yield i + } +} + +for (let num of counter(1, 5)) { + console.log(num) +} + + +async function complexNumberProcessing(n : number) : Promise { + return n +} + +async function foo() { + for (let i = 1; i <= 5; i++) { + console.log(await complexNumberProcessing(i)) + } +} + +foo() diff --git a/linter-4.2/test_rules/rule94.ts.autofix.json b/linter-4.2/test_rules/rule94.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..76137f30e856f3fb8a972b33ac7f50141317c5b8 --- /dev/null +++ b/linter-4.2/test_rules/rule94.ts.autofix.json @@ -0,0 +1,28 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "GeneratorFunction", + "autofixable": false, + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)" + }, + { + "line": 3, + "column": 9, + "problem": "YieldExpression", + "autofixable": false, + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)" + }, + { + "line": 7, + "column": 1, + "problem": "ForOfNonArray", + "autofixable": false, + "suggest": "", + "rule": "\"for-of\" is supported only for arrays and strings (arkts-for-of-str-arr)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule94.ts.relax.json b/linter-4.2/test_rules/rule94.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..71dfc04e8503e511a5325b956725c8392430e264 --- /dev/null +++ b/linter-4.2/test_rules/rule94.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "GeneratorFunction", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)" + }, + { + "line": 3, + "column": 9, + "problem": "YieldExpression", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule94.ts.strict.json b/linter-4.2/test_rules/rule94.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..731c598239e2e149caf884e25a56b7a8f5912c1f --- /dev/null +++ b/linter-4.2/test_rules/rule94.ts.strict.json @@ -0,0 +1,25 @@ +{ + "nodes": [ + { + "line": 1, + "column": 1, + "problem": "GeneratorFunction", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)" + }, + { + "line": 3, + "column": 9, + "problem": "YieldExpression", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)" + }, + { + "line": 7, + "column": 1, + "problem": "ForOfNonArray", + "suggest": "", + "rule": "\"for-of\" is supported only for arrays and strings (arkts-for-of-str-arr)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule96.ts b/linter-4.2/test_rules/rule96.ts new file mode 100644 index 0000000000000000000000000000000000000000..b71008939c74a8ef7c25026a5884bb042a2ffd13 --- /dev/null +++ b/linter-4.2/test_rules/rule96.ts @@ -0,0 +1,48 @@ +class Foo { + foo: number = 0 + common: string = "" +} + +class Bar { + bar: number = 0 + common: string = "" +} + +function isFoo(arg: any): arg is Foo { + return arg.foo !== undefined +} + +function doStuff(arg: Foo | Bar) { + if (isFoo(arg)) { + console.log(arg.foo) // OK + console.log(arg.bar) // Compile-time error + } else { + console.log(arg.foo) // Compile-time error + console.log(arg.bar) // OK + } +} + +doStuff({ foo: 123, common: '123' }) +doStuff({ bar: 123, common: '123' }) + + +function isFoo2(arg: Object): boolean { + return arg instanceof Foo +} + +function doStuff2(arg: Object): void { + if (isFoo2(arg)) { + let fooArg = arg as Foo + console.log(fooArg.foo) // OK + console.log(arg.bar) // Compile-time error + } else { + let barArg = arg as Bar + console.log(arg.foo) // Compile-time error + console.log(barArg.bar) // OK + } +} + +function main(): void { + doStuff2(new Foo()) + doStuff2(new Bar()) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule96.ts.autofix.json b/linter-4.2/test_rules/rule96.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..ab7af149df81809e0db820da977d159aeb4594f5 --- /dev/null +++ b/linter-4.2/test_rules/rule96.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 11, + "column": 21, + "problem": "AnyType", + "autofixable": false, + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 27, + "problem": "IsOperator", + "autofixable": false, + "suggest": "", + "rule": "Type guarding is supported with \"instanceof\" and \"as\" (arkts-no-is)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule96.ts.relax.json b/linter-4.2/test_rules/rule96.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..1840c43919814cec04b007eb8ff239eeda2624de --- /dev/null +++ b/linter-4.2/test_rules/rule96.ts.relax.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 11, + "column": 21, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 27, + "problem": "IsOperator", + "suggest": "", + "rule": "Type guarding is supported with \"instanceof\" and \"as\" (arkts-no-is)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule96.ts.strict.json b/linter-4.2/test_rules/rule96.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..1840c43919814cec04b007eb8ff239eeda2624de --- /dev/null +++ b/linter-4.2/test_rules/rule96.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 11, + "column": 21, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" + }, + { + "line": 11, + "column": 27, + "problem": "IsOperator", + "suggest": "", + "rule": "Type guarding is supported with \"instanceof\" and \"as\" (arkts-no-is)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule97.ts b/linter-4.2/test_rules/rule97.ts new file mode 100644 index 0000000000000000000000000000000000000000..d09329799c98d0546f37ffb10fc8043132da1f51 --- /dev/null +++ b/linter-4.2/test_rules/rule97.ts @@ -0,0 +1,30 @@ +class Point { + x: number = 1 + y: number = 2 +} + +type PointKeys = keyof Point // The type of PointKeys is "x" | "y" + +function getPropertyValue(obj: Point, key: PointKeys) { + return obj[key] +} + +let obj = new Point() +console.log(getPropertyValue(obj, "x")) +console.log(getPropertyValue(obj, "y")) + +function getPropertyValue1(obj: Point, key: string): number { + if (key == "x") { + return obj.x + } + if (key == "y") { + return obj.y + } + throw new Error() +} + +function main(): void { + let obj = new Point() + console.log(getPropertyValue1(obj, "x")) + console.log(getPropertyValue1(obj, "y")) +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule97.ts.autofix.json b/linter-4.2/test_rules/rule97.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..eac151554b783060d94a9f2f4bbd57be9e0b625f --- /dev/null +++ b/linter-4.2/test_rules/rule97.ts.autofix.json @@ -0,0 +1,20 @@ +{ + "nodes": [ + { + "line": 6, + "column": 18, + "problem": "KeyOfOperator", + "autofixable": false, + "suggest": "", + "rule": "\"keyof\" operator is not supported (arkts-no-keyof)" + }, + { + "line": 9, + "column": 12, + "problem": "PropertyAccessByIndex", + "autofixable": false, + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule97.ts.relax.json b/linter-4.2/test_rules/rule97.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..0a345106b985927ab2c7b64cd7b2be55704d451a --- /dev/null +++ b/linter-4.2/test_rules/rule97.ts.relax.json @@ -0,0 +1,11 @@ +{ + "nodes": [ + { + "line": 6, + "column": 18, + "problem": "KeyOfOperator", + "suggest": "", + "rule": "\"keyof\" operator is not supported (arkts-no-keyof)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule97.ts.strict.json b/linter-4.2/test_rules/rule97.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..6756e9a0b4fe9d095c3368f1a264299e19f03d0c --- /dev/null +++ b/linter-4.2/test_rules/rule97.ts.strict.json @@ -0,0 +1,18 @@ +{ + "nodes": [ + { + "line": 6, + "column": 18, + "problem": "KeyOfOperator", + "suggest": "", + "rule": "\"keyof\" operator is not supported (arkts-no-keyof)" + }, + { + "line": 9, + "column": 12, + "problem": "PropertyAccessByIndex", + "suggest": "", + "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts b/linter-4.2/test_rules/rule99.ts new file mode 100644 index 0000000000000000000000000000000000000000..61f72c85a8b3a2c0eddaa92e6977de9290e21fbf --- /dev/null +++ b/linter-4.2/test_rules/rule99.ts @@ -0,0 +1,48 @@ +function foo(x : number, y : number, z : number) { + console.log(x, y, z) +} + +let args : [number, number, number] = [0, 1, 2] +foo(...args) + +let list1 = [1, 2] +let list2 = [...list1, 3, 4] + +let point2d = {x: 1, y: 2} +let point3d = {...point2d, z: 3} + + + + +function sum_numbers(...numbers: number[]): number { + let res = 0 + for (let n of numbers) + res += n + return res +} +console.log(sum_numbers(1, 2, 3)) + +function log_numbers(x : number, y : number, z : number) { + console.log(x, y, z) +} +let numbers: number[] = [1, 2, 3] +log_numbers(numbers[0], numbers[1], numbers[2]) + +let list3 : number[] = [1, 2] +let list4 : number[] = [list1[0], list1[1], 3, 4] + +class Point2D { + x: number = 0; y: number = 0 +} + +class Point3D { + x: number = 0; y: number = 0; z: number = 0 + constructor(p2d: Point2D, z: number) { + this.x = p2d.x + this.y = p2d.y + this.z = z + } +} + +let p3d = new Point3D({x: 1, y: 2} as Point2D, 3) +console.log(p3d.x, p3d.y, p3d.z) \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts.autofix.json b/linter-4.2/test_rules/rule99.ts.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..b2639eb9742b478470719fa641a5c291905586ab --- /dev/null +++ b/linter-4.2/test_rules/rule99.ts.autofix.json @@ -0,0 +1,52 @@ +{ + "nodes": [ + { + "line": 5, + "column": 12, + "problem": "TupleType", + "autofixable": false, + "suggest": "", + "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" + }, + { + "line": 6, + "column": 5, + "problem": "SpreadOperator", + "autofixable": false, + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + }, + { + "line": 9, + "column": 14, + "problem": "SpreadOperator", + "autofixable": false, + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + }, + { + "line": 11, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 12, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "autofixable": false, + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 12, + "column": 16, + "problem": "SpreadOperator", + "autofixable": false, + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts.relax.json b/linter-4.2/test_rules/rule99.ts.relax.json new file mode 100644 index 0000000000000000000000000000000000000000..df5204fcfef2b49fc8e76bb7e97d0184c1f78336 --- /dev/null +++ b/linter-4.2/test_rules/rule99.ts.relax.json @@ -0,0 +1,46 @@ +{ + "nodes": [ + { + "line": 5, + "column": 12, + "problem": "TupleType", + "suggest": "", + "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" + }, + { + "line": 6, + "column": 5, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + }, + { + "line": 9, + "column": 14, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + }, + { + "line": 11, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 12, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 12, + "column": 16, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + } + ] +} \ No newline at end of file diff --git a/linter-4.2/test_rules/rule99.ts.strict.json b/linter-4.2/test_rules/rule99.ts.strict.json new file mode 100644 index 0000000000000000000000000000000000000000..df5204fcfef2b49fc8e76bb7e97d0184c1f78336 --- /dev/null +++ b/linter-4.2/test_rules/rule99.ts.strict.json @@ -0,0 +1,46 @@ +{ + "nodes": [ + { + "line": 5, + "column": 12, + "problem": "TupleType", + "suggest": "", + "rule": "Use \"Object[]\" instead of tuples (arkts-no-tuples)" + }, + { + "line": 6, + "column": 5, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + }, + { + "line": 9, + "column": 14, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + }, + { + "line": 11, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 12, + "column": 15, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)" + }, + { + "line": 12, + "column": 16, + "problem": "SpreadOperator", + "suggest": "", + "rule": "It is possible to spread only arrays into the rest parameter (arkts-no-spread)" + } + ] +} \ No newline at end of file diff --git a/linter/.gitignore b/linter/.gitignore index 4797db793b998b8c2ea246115378791d451072f7..3feb73341ba4f96fd83c2da4fba0914f5b416f10 100644 --- a/linter/.gitignore +++ b/linter/.gitignore @@ -8,4 +8,5 @@ cookbook_convertor/md .vscode .cache test/**/results +test_rules/**/results package-lock.json \ No newline at end of file diff --git a/linter/package.json b/linter/package.json index be08a5e89bf0fb103c3a7dbe5127abfecdc6b282..b9f16d7bfea4cd002a7886685cd4458a0a90d685 100644 --- a/linter/package.json +++ b/linter/package.json @@ -16,8 +16,10 @@ "build": "npm run clean && npm run compile && npm run webpack && npm run pack:linter", "postinstall": "npm run build", "pack:linter": "rimraf bundle && mkdir bundle && npm pack --pack-destination bundle", - "test": "npm run compile && rimraf test/results && node build/src/TestRunner.js test", - "rule_tests": "npm run compile && rimraf test_rules/results && node build/src/TestRunner.js test_rules" + "test": "npm run compile && rimraf test/results test_rules/results && node build/src/TestRunner.js test test_rules", + "test_main": "npm run compile && rimraf test/results && node build/src/TestRunner.js test", + "test_rules": "npm run compile && rimraf test_rules/results && node build/src/TestRunner.js test_rules", + "update-tests": "node scripts/update-test-results.mjs test test_rules" }, "dependencies": { "typescript": "4.8.4", diff --git a/linter/test/update-test-results.bat b/linter/scripts/update-test-results.bat similarity index 100% rename from linter/test/update-test-results.bat rename to linter/scripts/update-test-results.bat diff --git a/linter/test/update-test-results.mjs b/linter/scripts/update-test-results.mjs similarity index 68% rename from linter/test/update-test-results.mjs rename to linter/scripts/update-test-results.mjs index b750c0706ffe4da2e5de06b349c1d716986a62d5..dc579e42453a4416215504af7d0e3133221a4f33 100644 --- a/linter/test/update-test-results.mjs +++ b/linter/scripts/update-test-results.mjs @@ -34,8 +34,17 @@ const AUTOFIX_SKIP_EXT = '.autofix.skip'; const DIFF_EXT = '.diff'; const RESULTS_DIR = 'results' +let testDirs = []; + // forces to update all tests regardless of whether there was diff in a test result -const force_update = process.argv.includes('--force'); +const force_update = false; + +for (let arg of process.argv.slice(2)) { + if (arg === '--force') + force_update = true; + else + testDirs.push(arg); +} const DEFAULT_COPYRIGHT = [ "Copyright (c) 2023-2023 Huawei Device Co., Ltd.", @@ -61,25 +70,25 @@ function readTestFile(filePath) { } } -function updateTest(testFile, mode) { +function updateTest(testDir, testFile, mode) { let resultExt = RESULT_EXT[mode]; let testFileWithExt = testFile + resultExt; // Do not update autofix result if test is skipped - if (mode === Mode.AUTOFIX && fs.existsSync(testFile + AUTOFIX_SKIP_EXT)) { + if (mode === Mode.AUTOFIX && fs.existsSync(path.join(testDir, testFileWithExt + AUTOFIX_SKIP_EXT))) { return; } // Update test result when 'diff' exists or the 'force' option is enabled. - if (!fs.existsSync(path.join(RESULTS_DIR, testFileWithExt + DIFF_EXT)) && !force_update) { + if (!fs.existsSync(path.join(testDir, RESULTS_DIR, testFileWithExt + DIFF_EXT)) && !force_update) { return; } - let expectedResult = readTestFile(testFileWithExt); + let expectedResult = readTestFile(path.join(testDir, testFileWithExt)); const copyright = expectedResult?.copyright ?? DEFAULT_COPYRIGHT; - let actualResult = readTestFile(path.join(RESULTS_DIR, testFileWithExt)); + let actualResult = readTestFile(path.join(testDir, RESULTS_DIR, testFileWithExt)); if (!actualResult || !actualResult.nodes) { console.log(`Failed to update ${testFileWithExt}: couldn't read ACTUAL result file.`); return; @@ -87,28 +96,24 @@ function updateTest(testFile, mode) { // Write file with actual test results. let newResultJSON = JSON.stringify({ copyright, nodes: actualResult.nodes }, null, 4); - fs.writeFileSync(testFileWithExt, newResultJSON); + fs.writeFileSync(path.join(testDir, testFileWithExt), newResultJSON); console.log(`Updated ${testFileWithExt}`); } -if (!fs.existsSync(RESULTS_DIR)) { - console.log(`The ${RESULTS_DIR} dir does not exist!`); - process.exit(0); -} +for (let testDir of testDirs) { + if (!fs.existsSync(path.join(testDir, RESULTS_DIR))) continue; -// Get tests from test directory. -let testFiles = fs.readdirSync(".").filter(x => - (x.trimEnd().endsWith(TS_EXT) && !x.trimEnd().endsWith(D_TS_EXT)) || x.trimEnd().endsWith(TSX_EXT)); + // Get tests from test directory. + let testFiles = fs.readdirSync(testDir).filter(x => + (x.trimEnd().endsWith(TS_EXT) && !x.trimEnd().endsWith(D_TS_EXT)) || x.trimEnd().endsWith(TSX_EXT)); -if (!testFiles || testFiles.length == 0) { - console.log("No tests to update."); - process.exit(0); -} + if (!testFiles) continue; -// Update result for each test for Strict and Relax modes: -for (let testFile of testFiles) { - updateTest(testFile, Mode.RELAX); - updateTest(testFile, Mode.STRICT); - updateTest(testFile, Mode.AUTOFIX); + // Update result for each test for Strict and Relax modes: + for (let testFile of testFiles) { + updateTest(testDir, testFile, Mode.RELAX); + updateTest(testDir, testFile, Mode.STRICT); + updateTest(testDir, testFile, Mode.AUTOFIX); + } } \ No newline at end of file diff --git a/linter/test/update-test-results.sh b/linter/scripts/update-test-results.sh old mode 100755 new mode 100644 similarity index 100% rename from linter/test/update-test-results.sh rename to linter/scripts/update-test-results.sh diff --git a/linter/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index 51ee559c1dd4758fa87c8a0d8e2efb672f612c5d..4370ec6c13d101661032a018c4ae3363b4b56347 100644 --- a/linter/src/FaultAttrs.ts +++ b/linter/src/FaultAttrs.ts @@ -88,7 +88,6 @@ faultsAttrs[FaultID.ConstructorFuncs] = {cookBookRef: '106',}; faultsAttrs[FaultID.EnumMemberNonConstInit] = {cookBookRef: '111',}; faultsAttrs[FaultID.EnumMerging] = {cookBookRef: '113',}; faultsAttrs[FaultID.NamespaceAsObject] = {cookBookRef: '114',}; -faultsAttrs[FaultID.ClassAsObject] = {cookBookRef: '149',}; faultsAttrs[FaultID.NonDeclarationInNamespace] = {cookBookRef: '116',}; faultsAttrs[FaultID.ImportFromPath] = {cookBookRef: '119',}; faultsAttrs[FaultID.TypeOnlyImport] = {migratable: true, cookBookRef: '118',}; @@ -115,6 +114,7 @@ faultsAttrs[FaultID.LimitedStdLibApi] = {cookBookRef: '144',}; faultsAttrs[FaultID.StrictDiagnostic] = {cookBookRef: '145',}; faultsAttrs[FaultID.ErrorSuppression] = {cookBookRef: '146',}; faultsAttrs[FaultID.UnsupportedDecorators] = {cookBookRef: '148',}; +faultsAttrs[FaultID.ClassAsObject] = {cookBookRef: '149',}; faultsAttrs[FaultID.ImportAfterStatement] = {cookBookRef: '150',}; faultsAttrs[FaultID.EsObjectType] = {cookBookRef: '8'}; faultsAttrs[FaultID.EsObjectAssignment] = {cookBookRef: '8'}; diff --git a/linter/src/TestRunner.ts b/linter/src/TestRunner.ts index 2d8953ebf2c3bf5474a0ef00a487103c0fad7e2f..68826cb621572b0c4d1394c2d52b2123affe3266 100644 --- a/linter/src/TestRunner.ts +++ b/linter/src/TestRunner.ts @@ -52,7 +52,7 @@ const AUTOFIX_SKIP_EXT = '.autofix.skip'; const ARGS_CONFIG_EXT = '.args.json' const DIFF_EXT = '.diff'; -function runTests(baseDir: string): number { +function runTests(testDirs: string[]): number { let hasComparisonFailures = false; // Set the IDE mode manually to enable storing information @@ -60,37 +60,36 @@ function runTests(baseDir: string): number { TypeScriptLinter.ideMode = true; TypeScriptLinter.testMode = true; - // Get tests from test directory - const testDir = baseDir ?? TEST_DIR; - const testFiles: string[] = fs.readdirSync(testDir) - .filter((x) => (x.trimEnd().endsWith(ts.Extension.Ts) && !x.trimEnd().endsWith(ts.Extension.Dts)) || x.trimEnd().endsWith(ts.Extension.Tsx)); - - if (!testFiles || testFiles.length == 0) { - logger.info('No tests to run!'); - process.exit(0); - } - let passed = 0, failed = 0; - // Run each test in Strict, Autofix, and Relax mode: - for (const testFile of testFiles) { - if (runTest(testDir, testFile, Mode.STRICT)) { - failed++; - hasComparisonFailures = true; - } - else passed++; - - if (runTest(testDir, testFile, Mode.AUTOFIX)) { - failed++; - hasComparisonFailures = true; - } - else passed++; - - if (runTest(testDir, testFile, Mode.RELAX)) { - failed++; - hasComparisonFailures = true; + // Get tests from test directory + if (!testDirs?.length) testDirs = [ TEST_DIR ]; + for (const testDir of testDirs) { + let testFiles: string[] = fs.readdirSync(testDir) + .filter((x) => (x.trimEnd().endsWith(ts.Extension.Ts) && !x.trimEnd().endsWith(ts.Extension.Dts)) || x.trimEnd().endsWith(ts.Extension.Tsx)); + + logger.info(`\nProcessing "${testDir}" directory:\n`); + + // Run each test in Strict, Autofix, and Relax mode: + for (const testFile of testFiles) { + if (runTest(testDir, testFile, Mode.STRICT)) { + failed++; + hasComparisonFailures = true; + } + else passed++; + + if (runTest(testDir, testFile, Mode.AUTOFIX)) { + failed++; + hasComparisonFailures = true; + } + else passed++; + + if (runTest(testDir, testFile, Mode.RELAX)) { + failed++; + hasComparisonFailures = true; + } + else passed++; } - else passed++; } logger.info(`\nSUMMARY: ${passed + failed} total, ${passed} passed or skipped, ${failed} failed.`); @@ -241,4 +240,4 @@ ${actualNode}`; return diff; } -runTests(process.argv[2]); +runTests(process.argv.slice(2)); diff --git a/linter/src/utils/TsUtils.ts b/linter/src/utils/TsUtils.ts index 6aa0e781478a806727e0d66812182e7a81f70c0b..b532a1e800984482c561a123918c15ac582e20a6 100644 --- a/linter/src/utils/TsUtils.ts +++ b/linter/src/utils/TsUtils.ts @@ -949,15 +949,12 @@ export class TsUtils { if (type.isUnion()) { for (let compType of type.types) { - if (this.isLibraryType(compType)) { - return true; - } - - if (!isStdLibraryType(compType) && !isIntrinsicObjectType(compType) && !this.isAnyType(compType)) { - return false; + let isDynamic = this.isDynamicType(compType); + if (isDynamic || isDynamic === undefined) { + return isDynamic; } } - return undefined; + return false; } if (this.isLibraryType(type)) { diff --git a/linter/test/dynamic_lib.d.ts b/linter/test/dynamic_lib.d.ts index a9bb5c9a5de8a601b94c6468ce153b5eb8bbe6f9..b6a9493cb21c6446a5d06685e6fc3d87a0d9985c 100644 --- a/linter/test/dynamic_lib.d.ts +++ b/linter/test/dynamic_lib.d.ts @@ -48,3 +48,24 @@ export let dynamic_array: Array; export declare class C1 {} export declare function f2(c: C1): void; + +export type Length = string | number | Resource; +export interface Resource { + readonly id: number; + readonly type: number; +} +export type Padding = { + top?: Length; + right?: Length; + bottom?: Length; + left?: Length; +} +export type Margin = Padding; +export interface Position { + x?: Length; + y?: Length; +} + +export function padding(value: Padding | Length): any; +export function margin(value: Margin | Length): any; +export function position(value: Position): any; \ No newline at end of file diff --git a/linter/test/dynamic_object_literals.ts b/linter/test/dynamic_object_literals.ts index 7ed1e34799ca674b19c7a67ef566afdf2bb948c1..ea7f9759a2e8cf76d1eb0dd81536959bfcf1beeb 100644 --- a/linter/test/dynamic_object_literals.ts +++ b/linter/test/dynamic_object_literals.ts @@ -13,7 +13,19 @@ * limitations under the License. */ -import { I, foo, I2, I3, bar, C, getDynamicObject, dynamic_array } from "./dynamic_lib" +import { + I, + foo, + I2, + I3, + bar, + C, + getDynamicObject, + dynamic_array, + padding, + margin, + position +} from "./dynamic_lib" function main(): void { let obj: I = { @@ -67,4 +79,9 @@ function createInitProps(c: C) { } // #13483 - pass object literal to method call of exported variable -dynamic_array.splice(2, 0, {a: 1, b: '2'}); \ No newline at end of file +dynamic_array.splice(2, 0, {a: 1, b: '2'}); + +// #13550 - allow literals as property names in dynamic context +padding({'top': '0px', 'right': '5px', 'bottom': '10px', 'left': '15px'}); +margin({'top': '10px', 'right': '20px', 'bottom': '30px', 'left': '40px'}); +position({'x': '20', 'y': '40'}); \ No newline at end of file diff --git a/linter/test_rules/rule1.ts.autofix.json b/linter/test_rules/rule1.ts.autofix.json index ed9b9b05ad311a89340c9cdd69ae906f2a6e7023..32a60bb65fcb0cb40bb1b2c2b5f7a80779c2f0cf 100644 --- a/linter/test_rules/rule1.ts.autofix.json +++ b/linter/test_rules/rule1.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 2, @@ -21,13 +35,6 @@ "column": 10, "problem": "LiteralAsPropertyName", "autofixable": true, - "autofix": [ - { - "replacementText": "name", - "start": 10, - "end": 16 - } - ], "suggest": "", "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" }, @@ -36,13 +43,6 @@ "column": 21, "problem": "LiteralAsPropertyName", "autofixable": true, - "autofix": [ - { - "replacementText": "__2", - "start": 21, - "end": 22 - } - ], "suggest": "", "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)" }, @@ -51,13 +51,6 @@ "column": 13, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "x.name", - "start": 40, - "end": 49 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" }, @@ -66,13 +59,6 @@ "column": 13, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "x.__2", - "start": 63, - "end": 67 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" }, @@ -89,13 +75,6 @@ "column": 13, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "y.__2", - "start": 179, - "end": 183 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" } diff --git a/linter/test_rules/rule102.ts.autofix.json b/linter/test_rules/rule102.ts.autofix.json index cf4d6a275b5d92a6b6f53d847009cd7331733d5a..e9faca40d719a7792d52ff3cecb0c70eb6f8116c 100644 --- a/linter/test_rules/rule102.ts.autofix.json +++ b/linter/test_rules/rule102.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 1, @@ -38,7 +52,7 @@ "problem": "IntefaceExtendDifProps", "autofixable": false, "suggest": "", - "rule": "Interface declarations (extends same property) (arkts-no-extend-same-prop)" + "rule": "Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)" }, { "line": 9, diff --git a/linter/test_rules/rule102.ts.relax.json b/linter/test_rules/rule102.ts.relax.json index a9b169620ca63902e95a5e6cc883a803c67815a7..40159bc31eeb5e29cfdcab94c0b474731110546c 100644 --- a/linter/test_rules/rule102.ts.relax.json +++ b/linter/test_rules/rule102.ts.relax.json @@ -1,4 +1,18 @@ { + "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": 1, @@ -33,7 +47,7 @@ "column": 1, "problem": "IntefaceExtendDifProps", "suggest": "", - "rule": "Interface declarations (extends same property) (arkts-no-extend-same-prop)" + "rule": "Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)" }, { "line": 9, diff --git a/linter/test_rules/rule102.ts.strict.json b/linter/test_rules/rule102.ts.strict.json index a9b169620ca63902e95a5e6cc883a803c67815a7..40159bc31eeb5e29cfdcab94c0b474731110546c 100644 --- a/linter/test_rules/rule102.ts.strict.json +++ b/linter/test_rules/rule102.ts.strict.json @@ -1,4 +1,18 @@ { + "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": 1, @@ -33,7 +47,7 @@ "column": 1, "problem": "IntefaceExtendDifProps", "suggest": "", - "rule": "Interface declarations (extends same property) (arkts-no-extend-same-prop)" + "rule": "Interface can not extend interfaces with the same method (arkts-no-extend-same-prop)" }, { "line": 9, diff --git a/linter/test_rules/rule103.ts.autofix.json b/linter/test_rules/rule103.ts.autofix.json index 644a4887f146d41853db3b27bb934360a2dbbecc..0b80e8ace95cd0133057e4dfd14154cf74cd98bb 100644 --- a/linter/test_rules/rule103.ts.autofix.json +++ b/linter/test_rules/rule103.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 1, @@ -14,7 +28,7 @@ "problem": "DeclWithDuplicateName", "autofixable": false, "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" }, { "line": 2, @@ -38,7 +52,7 @@ "problem": "DeclWithDuplicateName", "autofixable": false, "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" }, { "line": 9, @@ -54,7 +68,7 @@ "problem": "DeclWithDuplicateName", "autofixable": false, "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule103.ts.strict.json b/linter/test_rules/rule103.ts.strict.json index 0e46ba12fe32ffe76ba1484ace3be342089285ad..ed74f56a2af3396ac4bf837d4902413f1510e660 100644 --- a/linter/test_rules/rule103.ts.strict.json +++ b/linter/test_rules/rule103.ts.strict.json @@ -1,4 +1,18 @@ { + "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": 1, @@ -12,7 +26,7 @@ "column": 1, "problem": "DeclWithDuplicateName", "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" }, { "line": 2, @@ -33,7 +47,7 @@ "column": 1, "problem": "DeclWithDuplicateName", "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" }, { "line": 9, @@ -47,7 +61,7 @@ "column": 1, "problem": "DeclWithDuplicateName", "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule106.ts.autofix.json b/linter/test_rules/rule106.ts.autofix.json index c889e96a624f869ebe12f79726ce2dbd72169fb7..c9ee8bc8e4e80e31f467dc3fe97f4e19f860f435 100644 --- a/linter/test_rules/rule106.ts.autofix.json +++ b/linter/test_rules/rule106.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 7, @@ -13,7 +27,8 @@ "column": 29, "problem": "ClassAsObject", "autofixable": false, - "rule": "Classes cannot be used as objects (arkts-no-classes-as-objects)" + "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/rule106.ts.relax.json b/linter/test_rules/rule106.ts.relax.json index 501e2b9e402264aed188f380e0ce72f53802a9fa..9af8cdfaaa39ec4cb6fe53f12172134a15d40320 100644 --- a/linter/test_rules/rule106.ts.relax.json +++ b/linter/test_rules/rule106.ts.relax.json @@ -1,4 +1,18 @@ { + "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": 7, @@ -11,7 +25,8 @@ "line": 14, "column": 29, "problem": "ClassAsObject", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-objects)" + "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/rule106.ts.strict.json b/linter/test_rules/rule106.ts.strict.json index 501e2b9e402264aed188f380e0ce72f53802a9fa..9af8cdfaaa39ec4cb6fe53f12172134a15d40320 100644 --- a/linter/test_rules/rule106.ts.strict.json +++ b/linter/test_rules/rule106.ts.strict.json @@ -1,4 +1,18 @@ { + "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": 7, @@ -11,7 +25,8 @@ "line": 14, "column": 29, "problem": "ClassAsObject", - "rule": "Classes cannot be used as objects (arkts-no-classes-as-objects)" + "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/rule139.ts.autofix.json b/linter/test_rules/rule139.ts.autofix.json index fdf87817ea96fcf6f928eb5b067a44b16cb5efea..889c717b6ca43ea3988145aed051d7e3443656f0 100644 --- a/linter/test_rules/rule139.ts.autofix.json +++ b/linter/test_rules/rule139.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 6, @@ -8,6 +22,14 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "autofixable": false, + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, { "line": 20, "column": 1, diff --git a/linter/test_rules/rule139.ts.relax.json b/linter/test_rules/rule139.ts.relax.json index 17815b317fb30dd575e06483157f77b8b5636c80..b7b7c9f37a09769d65176147832a357c71d72ac1 100644 --- a/linter/test_rules/rule139.ts.relax.json +++ b/linter/test_rules/rule139.ts.relax.json @@ -1,4 +1,18 @@ { + "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": 6, @@ -7,6 +21,13 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, { "line": 20, "column": 1, diff --git a/linter/test_rules/rule139.ts.strict.json b/linter/test_rules/rule139.ts.strict.json index b90af5917f56111cd284bd0e619d5d3d10767a5c..29d46120970162586aceb5836230bd982d40e73d 100644 --- a/linter/test_rules/rule139.ts.strict.json +++ b/linter/test_rules/rule139.ts.strict.json @@ -1,4 +1,18 @@ { + "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": 6, @@ -7,6 +21,13 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, { "line": 20, "column": 1, diff --git a/linter/test_rules/rule140.ts.autofix.json b/linter/test_rules/rule140.ts.autofix.json index fdf87817ea96fcf6f928eb5b067a44b16cb5efea..889c717b6ca43ea3988145aed051d7e3443656f0 100644 --- a/linter/test_rules/rule140.ts.autofix.json +++ b/linter/test_rules/rule140.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 6, @@ -8,6 +22,14 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "autofixable": false, + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, { "line": 20, "column": 1, diff --git a/linter/test_rules/rule140.ts.relax.json b/linter/test_rules/rule140.ts.relax.json index 17815b317fb30dd575e06483157f77b8b5636c80..b7b7c9f37a09769d65176147832a357c71d72ac1 100644 --- a/linter/test_rules/rule140.ts.relax.json +++ b/linter/test_rules/rule140.ts.relax.json @@ -1,4 +1,18 @@ { + "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": 6, @@ -7,6 +21,13 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, { "line": 20, "column": 1, diff --git a/linter/test_rules/rule140.ts.strict.json b/linter/test_rules/rule140.ts.strict.json index b90af5917f56111cd284bd0e619d5d3d10767a5c..29d46120970162586aceb5836230bd982d40e73d 100644 --- a/linter/test_rules/rule140.ts.strict.json +++ b/linter/test_rules/rule140.ts.strict.json @@ -1,4 +1,18 @@ { + "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": 6, @@ -7,6 +21,13 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)" }, + { + "line": 20, + "column": 1, + "problem": "MethodReassignment", + "suggest": "", + "rule": "Reassigning object methods is not supported (arkts-no-method-reassignment)" + }, { "line": 20, "column": 1, diff --git a/linter/test_rules/rule147.ts.autofix.json b/linter/test_rules/rule147.ts.autofix.json index fb48725089f9e03d89950b514efe08731543705a..819d36d95dbe8467aa470cf1e0b34f80c10e3041 100644 --- a/linter/test_rules/rule147.ts.autofix.json +++ b/linter/test_rules/rule147.ts.autofix.json @@ -1,10 +1,25 @@ { + "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": 7, "column": 5, "problem": "ImportAfterStatement", "autofixable": false, + "suggest": "", "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" }, { @@ -13,7 +28,7 @@ "problem": "DeclWithDuplicateName", "autofixable": false, "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule147.ts.strict.json b/linter/test_rules/rule147.ts.strict.json index 7ea8c26212ace46911f6f67a6c08633860240d62..99874461dd58d4c43e2effdc6b727ab36d596c20 100644 --- a/linter/test_rules/rule147.ts.strict.json +++ b/linter/test_rules/rule147.ts.strict.json @@ -1,9 +1,24 @@ { + "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": 7, "column": 5, "problem": "ImportAfterStatement", + "suggest": "", "rule": "\"import\" statements after other statements are not allowed (arkts-no-misplaced-imports)" }, { @@ -11,7 +26,7 @@ "column": 14, "problem": "DeclWithDuplicateName", "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule17.ts.autofix.json b/linter/test_rules/rule17.ts.autofix.json index b86e0ccaf9c745c02c6f3c965e9097f6f7774461..dcd0bb1a10489e014cc5d82fbb5af47c4c85657a 100644 --- a/linter/test_rules/rule17.ts.autofix.json +++ b/linter/test_rules/rule17.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 2, @@ -13,13 +27,6 @@ "column": 20, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "myArray.__1", - "start": 192, - "end": 202 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" } diff --git a/linter/test_rules/rule29.ts.autofix.json b/linter/test_rules/rule29.ts.autofix.json index 61c7ba87ec5c08d658035618ac152e9f4638e273..7ce06f06c2b63c11a7b60f4d0f4051c4993d2f6a 100644 --- a/linter/test_rules/rule29.ts.autofix.json +++ b/linter/test_rules/rule29.ts.autofix.json @@ -1,17 +1,24 @@ { + "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": 3, "column": 9, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "p.x", - "start": 79, - "end": 85 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" } diff --git a/linter/test_rules/rule31.ts.autofix.json b/linter/test_rules/rule31.ts.autofix.json index 6257255e12f4802e4a2334969bd1ce48979d088d..93738805a7df6e3e2207d426cf229e22c910930f 100644 --- a/linter/test_rules/rule31.ts.autofix.json +++ b/linter/test_rules/rule31.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 21, @@ -6,7 +20,7 @@ "problem": "StructuralIdentity", "autofixable": false, "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" }, { "line": 24, @@ -14,7 +28,7 @@ "problem": "StructuralIdentity", "autofixable": false, "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule31.ts.relax.json b/linter/test_rules/rule31.ts.relax.json index a374418924df7edf7fd928518517511edd106fe8..278f67e075e50e473695d02ccecd87d657eecd35 100644 --- a/linter/test_rules/rule31.ts.relax.json +++ b/linter/test_rules/rule31.ts.relax.json @@ -1,18 +1,32 @@ { + "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": 21, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" }, { "line": 24, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule31.ts.strict.json b/linter/test_rules/rule31.ts.strict.json index a374418924df7edf7fd928518517511edd106fe8..278f67e075e50e473695d02ccecd87d657eecd35 100644 --- a/linter/test_rules/rule31.ts.strict.json +++ b/linter/test_rules/rule31.ts.strict.json @@ -1,18 +1,32 @@ { + "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": 21, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" }, { "line": 24, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule32.ts.autofix.json b/linter/test_rules/rule32.ts.autofix.json index 1c1802d5e46ec3fcb61201e73d1b79f4fafd2edc..a932e2c692195391c6df4a6cf944922cf4c82ddb 100644 --- a/linter/test_rules/rule32.ts.autofix.json +++ b/linter/test_rules/rule32.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 20, @@ -6,7 +20,7 @@ "problem": "StructuralIdentity", "autofixable": false, "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" }, { "line": 23, @@ -14,7 +28,7 @@ "problem": "StructuralIdentity", "autofixable": false, "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule32.ts.relax.json b/linter/test_rules/rule32.ts.relax.json index 433020aca97b1c18c852b507ccbd74aa634689f3..6446311e96b34209987d92c55030890877d3263b 100644 --- a/linter/test_rules/rule32.ts.relax.json +++ b/linter/test_rules/rule32.ts.relax.json @@ -1,18 +1,32 @@ { + "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": 20, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" }, { "line": 23, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule32.ts.strict.json b/linter/test_rules/rule32.ts.strict.json index 433020aca97b1c18c852b507ccbd74aa634689f3..6446311e96b34209987d92c55030890877d3263b 100644 --- a/linter/test_rules/rule32.ts.strict.json +++ b/linter/test_rules/rule32.ts.strict.json @@ -1,18 +1,32 @@ { + "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": 20, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" }, { "line": 23, "column": 1, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule35.ts.autofix.json b/linter/test_rules/rule35.ts.autofix.json index 1bca487a8e8aaa78b8b8177e87edd1ec333bdfa2..b58aa1b185222f8038191a96680f00b1f7c7de9e 100644 --- a/linter/test_rules/rule35.ts.autofix.json +++ b/linter/test_rules/rule35.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 31, @@ -6,7 +20,7 @@ "problem": "StructuralIdentity", "autofixable": false, "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule35.ts.relax.json b/linter/test_rules/rule35.ts.relax.json index aae7e0324697b533e50106a4f042b05639c889db..f2b48d95a67d9862e0165b3bde40d481d2e1ed27 100644 --- a/linter/test_rules/rule35.ts.relax.json +++ b/linter/test_rules/rule35.ts.relax.json @@ -1,11 +1,25 @@ { + "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": 31, "column": 5, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule35.ts.strict.json b/linter/test_rules/rule35.ts.strict.json index aae7e0324697b533e50106a4f042b05639c889db..f2b48d95a67d9862e0165b3bde40d481d2e1ed27 100644 --- a/linter/test_rules/rule35.ts.strict.json +++ b/linter/test_rules/rule35.ts.strict.json @@ -1,11 +1,25 @@ { + "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": 31, "column": 5, "problem": "StructuralIdentity", "suggest": "", - "rule": "Structural identity is not supported (arkts-no-structural-identity)" + "rule": "Structural typing is not supported (arkts-no-structural-typing)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule4.ts.autofix.json b/linter/test_rules/rule4.ts.autofix.json index ee484068a3debc4ee811d6eb896e7fee745a8e72..ba15a33cf59aebf7b21ab330280fe27cab3ac874 100644 --- a/linter/test_rules/rule4.ts.autofix.json +++ b/linter/test_rules/rule4.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 1, @@ -6,7 +20,7 @@ "problem": "DeclWithDuplicateName", "autofixable": false, "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" }, { "line": 2, @@ -14,7 +28,7 @@ "problem": "DeclWithDuplicateName", "autofixable": false, "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule4.ts.strict.json b/linter/test_rules/rule4.ts.strict.json index ba18acad623ce8b6ccc3c61b15ee614cd11d7ab7..9dda4cf2161cbbdb25d061ecd071e1d6774d6fdb 100644 --- a/linter/test_rules/rule4.ts.strict.json +++ b/linter/test_rules/rule4.ts.strict.json @@ -1,18 +1,32 @@ { + "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": 1, "column": 5, "problem": "DeclWithDuplicateName", "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" }, { "line": 2, "column": 1, "problem": "DeclWithDuplicateName", "suggest": "", - "rule": "Use unique names for types, namespaces, etc. (arkts-unique-names)" + "rule": "Use unique names for types and namespaces. (arkts-unique-names)" } ] } \ No newline at end of file diff --git a/linter/test_rules/rule52.ts.autofix.json b/linter/test_rules/rule52.ts.autofix.json index 4fc1a46af8b22b14eac8f65acf231ebba6b3f930..d08778c7501b273c17067d79c05b867059b61441 100644 --- a/linter/test_rules/rule52.ts.autofix.json +++ b/linter/test_rules/rule52.ts.autofix.json @@ -1,4 +1,18 @@ { + "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": 1, @@ -13,13 +27,6 @@ "column": 9, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "person.name", - "start": 54, - "end": 68 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" }, @@ -28,13 +35,6 @@ "column": 9, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "person.isEmployee", - "start": 77, - "end": 97 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" }, @@ -51,13 +51,6 @@ "column": 9, "problem": "PropertyAccessByIndex", "autofixable": true, - "autofix": [ - { - "replacementText": "person.office", - "start": 106, - "end": 122 - } - ], "suggest": "", "rule": "Indexed access is not supported for fields (arkts-no-props-by-index)" }