diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index a15641503fd7aa6af889b0b1b95a5af54dd1809e..24f640d2bea6058fdb40d9ca36a3432c8c4bc787 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -693,8 +693,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleInvalidIdentifier(tsParam); this.handleSdkGlobalApi(tsParam); const typeNode = tsParam.type; - if (this.options.arkts2 && typeNode && typeNode.kind === ts.SyntaxKind.VoidKeyword) { - this.incrementCounters(typeNode, FaultID.LimitedVoidType); + if (this.options.arkts2 && typeNode && TsUtils.typeContainsVoid(typeNode)) { + const autofix = this.autofixer?.fixLimitedVoidType(tsParam); + this.incrementCounters(typeNode, FaultID.LimitedVoidType, autofix); } this.handlePropertyDescriptorInScenarios(tsParam); } @@ -1631,8 +1632,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); const classDecorators = ts.getDecorators(node.parent); const propType = node.type?.getText(); - if (this.options.arkts2 && propType === 'void' && node.type) { - this.incrementCounters(node.type, FaultID.LimitedVoidType); + if (this.options.arkts2 && node.type && TsUtils.typeContainsVoid(node.type)) { + const autofix = this.autofixer?.fixLimitedVoidType(node); + this.incrementCounters(node.type, FaultID.LimitedVoidType, autofix); } this.filterOutDecoratorsDiagnostics( classDecorators, @@ -1907,6 +1909,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (hasUnfixableReturnType) { this.incrementCounters(funcExpr, FaultID.LimitedReturnTypeInference); } + this.handleLimitedVoidFunction(funcExpr); } private handleArrowFunction(node: ts.Node): void { @@ -1921,6 +1924,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } this.checkDefaultParamBeforeRequired(arrowFunc); + this.handleLimitedVoidFunction(arrowFunc); } private handleFunctionDeclaration(node: ts.Node): void { @@ -1966,6 +1970,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkAssignmentNumericSemanticsFuntion(tsFunctionDeclaration); this.handleInvalidIdentifier(tsFunctionDeclaration); this.checkDefaultParamBeforeRequired(tsFunctionDeclaration); + this.handleLimitedVoidFunction(tsFunctionDeclaration); } private handleMissingReturnType( @@ -3542,6 +3547,21 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.checkDefaultParamBeforeRequired(tsMethodDecl); this.handleMethodInherit(tsMethodDecl); this.handleSdkGlobalApi(tsMethodDecl); + this.handleLimitedVoidFunction(tsMethodDecl); + } + + private handleLimitedVoidFunction(node: ts.FunctionLikeDeclaration): void { + const typeNode = node.type; + if (!typeNode || !ts.isUnionTypeNode(typeNode)) { + return; + } + const containsVoid = typeNode.types.some((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword; + }); + if (this.options.arkts2 && containsVoid) { + const autofix = this.autofixer?.fixLimitedVoidTypeFunction(node); + this.incrementCounters(typeNode, FaultID.LimitedVoidType, autofix); + } } private checkDefaultParamBeforeRequired(node: ts.FunctionLikeDeclarationBase): void { @@ -6235,8 +6255,9 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const typeNode = node.type; - if (typeNode && typeNode.kind === ts.SyntaxKind.VoidKeyword) { - this.incrementCounters(typeNode, FaultID.LimitedVoidType); + if (typeNode && TsUtils.typeContainsVoid(typeNode)) { + const autofix = this.autofixer?.fixLimitedVoidType(node); + this.incrementCounters(typeNode, FaultID.LimitedVoidType, autofix); } } diff --git a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts index ea1c6efe252606b48b61c3351cda0352238c02fe..9a990259ea0cad8df51146c13bef1ff9342b114f 100644 --- a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts +++ b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts @@ -38,6 +38,7 @@ export const cookBookRefToFixTitle: Map = new Map([ [177, 'Add \'Sendable\' decorator'], [180, 'Remove the decorator'], [189, 'Add type annotations to numerical variables'], + [192, 'Use "undefined" instead "void"'], [193, 'Replace with arrow function'], [209, 'Transform "number" to "int"'], [251, 'Transform "!!" to "$$()"'], diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 4ae5c879821774aeb3227d627adc77c4a51a738c..5bc997f00867660ec064693b3c03d3a9d6bec0bd 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -4701,6 +4701,139 @@ export class Autofixer { return !builtInTypes.has(type.typeName.getText()); } + fixLimitedVoidType( + node: ts.VariableDeclaration | ts.ParameterDeclaration | ts.PropertyDeclaration + ): Autofix[] | undefined { + const srcFile = node.getSourceFile(); + const newType = Autofixer.createNewTypeFromVoid(node.type); + const newInit = Autofixer.createNewInitializer(node.initializer, newType); + + const newDecl = Autofixer.createNewDeclaration(node, newType, newInit); + if (!newDecl) { + return undefined; + } + + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, newDecl, srcFile); + return [{ start: node.getStart(), end: node.getEnd(), replacementText }]; + } + + private static createNewTypeFromVoid(type: ts.TypeNode | undefined): ts.TypeNode { + const identUndefined = ts.factory.createIdentifier(UNDEFINED_NAME); + if (type && ts.isUnionTypeNode(type)) { + const updatedTypes = type.types.map((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword ? ts.factory.createTypeReferenceNode(UNDEFINED_NAME) : t; + }); + return ts.factory.createUnionTypeNode(updatedTypes); + } + return ts.factory.createTypeReferenceNode(identUndefined); + } + + private static createNewInitializer(initializer: ts.Expression | undefined, newType: ts.TypeNode): ts.Expression { + const identUndefined = ts.factory.createIdentifier(UNDEFINED_NAME); + if (!initializer) { + return identUndefined; + } + + const stmts: ts.Statement[] = [ + ts.factory.createExpressionStatement(initializer), + ts.factory.createReturnStatement(identUndefined) + ]; + const funcBody = ts.factory.createBlock(stmts); + const arrowFunc = ts.factory.createArrowFunction( + undefined, + undefined, + [], + newType, + ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + funcBody + ); + return ts.factory.createCallExpression(ts.factory.createParenthesizedExpression(arrowFunc), undefined, undefined); + } + + private static createNewDeclaration( + node: ts.VariableDeclaration | ts.ParameterDeclaration | ts.PropertyDeclaration, + newType: ts.TypeNode, + newInit: ts.Expression + ): ts.Node | undefined { + if (ts.isVariableDeclaration(node)) { + return ts.factory.createVariableDeclaration(node.name, node.exclamationToken, newType, newInit); + } + + if (ts.isParameter(node)) { + return ts.factory.createParameterDeclaration( + node.modifiers, + node.dotDotDotToken, + node.name, + node.questionToken, + newType, + node.initializer ? newInit : undefined + ); + } + + if (ts.isPropertyDeclaration(node)) { + const optionalToken = node.questionToken || node.exclamationToken; + return ts.factory.createPropertyDeclaration(node.modifiers, node.name, optionalToken, newType, newInit); + } + + return undefined; + } + + /** + * Fixes function declarations/expressions that return `void` as part of a union. + * Replaces `void` with `undefined` in the return type, + * replaces `return;` with `return undefined;`, + * and adds `return undefined;` if the function has no returns. + */ + fixLimitedVoidTypeFunction(fn: ts.FunctionLikeDeclaration): Autofix[] | undefined { + const fixes: Autofix[] = []; + const returnType = fn.type; + if (!returnType || !ts.isUnionTypeNode(returnType) || !TsUtils.typeContainsVoid(returnType)) { + return undefined; + } + + const updatedTypes = returnType.types.map((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword ? ts.factory.createTypeReferenceNode(UNDEFINED_NAME) : t; + }); + + const newType = ts.factory.createUnionTypeNode(updatedTypes); + fixes.push({ + start: returnType.getStart(), + end: returnType.getEnd(), + replacementText: this.printer.printNode(ts.EmitHint.Unspecified, newType, fn.getSourceFile()) + }); + + let hasReturn = false; + function visit(node: ts.Node): void { + if (ts.isReturnStatement(node)) { + hasReturn = true; + if (!node.expression) { + fixes.push({ + start: node.getStart(), + end: node.getEnd(), + replacementText: 'return undefined;' + }); + } + } + ts.forEachChild(node, visit); + } + if (fn.body) { + visit(fn.body); + + if (!hasReturn) { + if (ts.isBlock(fn.body)) { + const lastBrace = fn.body.getEnd() - 1; + fixes.push({ + start: lastBrace, + end: lastBrace, + replacementText: '\nreturn undefined;\n' + }); + } + } + } + + return fixes; + } + fixGenericCallNoTypeArgs(node: ts.NewExpression): Autofix[] | undefined { const typeNode = this.getTypeNodeForNewExpression(node); if (!typeNode || !ts.isTypeReferenceNode(typeNode) || typeNode.typeName.getText() !== node.expression.getText()) { diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index 3a0f7b32ebe57a38f96c7523576958f26d040654..7985be2983f69667050e160f1b4a8fd01efdc525 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -3807,4 +3807,13 @@ export class TsUtils { forEachNodeInSubtree(targetNode, callback, stopCondition); return found; } + + static typeContainsVoid(typeNode: ts.TypeNode): boolean { + if (ts.isUnionTypeNode(typeNode)) { + return typeNode.types.some((t) => { + return t.kind === ts.SyntaxKind.VoidKeyword; + }); + } + return typeNode.kind === ts.SyntaxKind.VoidKeyword; + } } diff --git a/ets2panda/linter/test/main/limit_void_type.ets b/ets2panda/linter/test/main/limit_void_type.ets index 7296884de62f443938edb8ff3799aba7e688fb8c..7cb24cf7cfb7aa299b8e290353cd57922ef97bd8 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets +++ b/ets2panda/linter/test/main/limit_void_type.ets @@ -15,48 +15,48 @@ // Example 1: Basic function -function func1(): void {} +function func1(): void { } let a: void = func1(); // Example 2: Arrow function -const func2 = (): void => {}; +const func2 = (): void => { }; let b: void = func2(); // Example 3: Class method class Demo { - method(): void {} + method(): void { } } let c: void = new Demo().method(); // Example 4: Immediately Invoked Function Expression (IIFE) -let d: void = (function(): void {})(); +let d: void = (function (): void { })(); // Example 5: Asynchronous function -async function asyncFunc(): Promise {} +async function asyncFunc(): Promise { } let e: void = await asyncFunc(); // Example 6: Function parameter function wrapper(fn: () => void) { let f: void = fn(); } // Example 7: Type assertion -function func3(): void {} +function func3(): void { } let g: void = func3() as void; // Example 8: Callback function -setTimeout((): void => {}, 1000); -let h: void = setTimeout(() => {}, 1000); +setTimeout((): void => { }, 1000); +let h: void = setTimeout(() => { }, 1000); // Example 9: Array operation -const funcArr: (() => void)[] = [() => {}]; +const funcArr: (() => void)[] = [() => { }]; let i: void = funcArr[0](); // Example 10: Object method const obj = { - action: (): void => {} + action: (): void => { } }; let j: void = obj.action(); // Example 11: Strict mode // @ts-strict -function func4(): void {} +function func4(): void { } let k: void = func4(); // Example 12: Module export -export function exportedFunc(): void {} +export function exportedFunc(): void { } let l: void = exportedFunc(); // Example 13: Generic function -function genericFunc(): void {} +function genericFunc(): void { } let m: void = genericFunc(); // Example 14: Function overloading function overloadFunc(): void; @@ -65,24 +65,24 @@ function overloadFunc(n?: number) { return n; } let n: void = overloadFunc(); // Example 15: Type alias type VoidFunc = () => void; -const aliasFunc: VoidFunc = () => {}; +const aliasFunc: VoidFunc = () => { }; let o: void = aliasFunc(); // Example 16: Interface implementation interface Task { run(): void; } class Printer implements Task { - run(): void {} + run(): void { } } let p: void = new Printer().run(); // Example 17: Optional parameter -function withParam(param?: string): void {} +function withParam(param?: string): void { } let q: void = withParam(); // Example 18: Rest parameter -function sum(...nums: number[]): void {} +function sum(...nums: number[]): void { } let r: void = sum(1, 2, 3); // Example 19: This parameter -function withThis(this: Window): void {} +function withThis(this: Window): void { } let s: void = withThis.call(window); // Example 20: Generator function function* genFunc(): Generator { @@ -90,31 +90,31 @@ function* genFunc(): Generator { } let u: void = genFunc().next().value; // Example 21: Function currying -const curry = () => (): void => {}; +const curry = () => (): void => { }; let w: void = curry()(); // Example 22: Method chaining class Chain { first(): this { return this; } - last(): void {} + last(): void { } } let x: void = new Chain().first().last(); // Example 23: Destructuring assignment -const [func] = [(): void => {}]; +const [func] = [(): void => { }]; let y: void = func(); // Example 24: Type mapping type Wrapper = { value: T }; -const wrapped: Wrapper<() => void> = { value: () => {} }; +const wrapped: Wrapper<() => void> = { value: () => { } }; let z: void = wrapped.value(); // Example 25: Conditional type type Conditional = T extends boolean ? () => void : never; -const condFunc: Conditional = () => {}; +const condFunc: Conditional = () => { }; let aa: void = condFunc(); // Example 26: Mixed type interface Mixed { (): void; prop: string; } -const mixed: Mixed = Object.assign(() => {}, { prop: "" }); +const mixed: Mixed = Object.assign(() => { }, { prop: "" }); let ab: void = mixed(); // Example 27: Recursive call function recursive(): void { @@ -123,13 +123,13 @@ function recursive(): void { let ac: void = recursive(); // Example 28: Decorator function function decorator() { - return function(target: any) {}; + return function (target: any) { }; } @decorator() -class Decorated {} +class Decorated { } let ad: void = decorator()(Decorated); -function f1(): void {} +function f1(): void { } let a1 = f1(); // type `void` is used as value @@ -145,24 +145,24 @@ a3[0] = f1(); // type `void` is used as value let a4: void = f1(); // type `void` is used as type annotation -function f2(a: void) {} // type `void` is used as type annotation +function f2(a: void) { } // type `void` is used as type annotation f2(f1()); // type `void` is used as value class A { f: void; // type `void` is used as type annotation - m(p: void) {} // type `void` is used as type annotation + m(p: void) { } // type `void` is used as type annotation constructor(a: void) { // type `void` is used as type annotation this.f = a; } } -function f3(): void | Promise {} // type `void` is not allowed in union type +function f3(): void | Promise { } // type `void` is not allowed in union type class B { - m(): void | number {} // type `void` is not allowed in union type + m(): void | number { } // type `void` is not allowed in union type } type ss = void; @@ -178,20 +178,20 @@ interface BT { } class C { - private cc?:BT; + private cc?: BT; - private d():void { + private d(): void { this.cc = { - qaq: (caller?:string):void => this.qaqq(caller) + qaq: (caller?: string): void => this.qaqq(caller) } } - private qaqq(caller?:string):void { + private qaqq(caller?: string): void { return; } } -function foo(): void {} -function bar(): void {} +function foo(): void { } +function bar(): void { } let aa = '1'; let bb = aa === '1' ? foo() : bar(); // Error @@ -199,11 +199,65 @@ let bb = aa === '1' ? foo() : bar(); // Error aa === '1' ? foo() : bar(); // No error let dd; dd = aa === '1' ? foo() : bar(); // Error -interface testB{ - u:void; // Error - fooIf():void; +interface testB { + u: void; // Error + fooIf(): void; } function foo1():void{ return foo(); // No Error +} + +function foocfe(a: number): string | void { + if (a >= 0) { + return "a >= 0"; + } +} + +function foocfe2(a: number): string | void { + if (a < 0) { + return; + } + return "a >= 0"; +} +function fooefc(): void { } +let ss: void = foo() +let t: void | number = foo() +let t2: void | number = 1; + +function greet(hour: number): string | void { + if (hour < 12) { + return; + } else if (hour < 18) { + return "Good afternoon"; + } else { + return; + } +} + +function logOrReturn(flag: boolean): string | void { + if (flag) { + return "Flag is true"; + } + console.log("Flag is false"); + return; +} + +function justLogs(): string | void { + console.log("Hello!"); +} + +function getStatus(code: number): string | void { + switch (code) { + case 1: return "OK"; + case 2: return "Warning"; + } +} + +function tryThing(): string | void { + try { + return "Worked!"; + } catch (e) { + console.error(e); + } } \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.args.json b/ets2panda/linter/test/main/limit_void_type.ets.args.json index 948b846fe04969bf5ccbe8bd9dc4a18559ce0c2c..571ee6bb76b0cad72a9443db47c2f9d7db474bd0 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.args.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.args.json @@ -1,19 +1,21 @@ { - "copyright": [ - "Copyright (c) 2025 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." - ], - "mode": { - "arkts2": "" - } + "copyright": [ + "Copyright (c) 2025 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." + ], + "mode": { + "arkts2": "", + "autofix": "--arkts-2", + "migrate": "--arkts-2" + } } diff --git a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json index 5a91df9df0075858aa94533bc5b79e47a6ced5dc..8a91a2e1a54a2aae0ac54f5bc5c8f1a0b2eefebc 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.arkts2.json @@ -88,7 +88,7 @@ "line": 29, "column": 15, "endLine": 29, - "endColumn": 38, + "endColumn": 40, "problem": "LimitedVoidType", "suggest": "", "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", @@ -98,7 +98,7 @@ "line": 29, "column": 16, "endLine": 29, - "endColumn": 35, + "endColumn": 37, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -156,9 +156,9 @@ }, { "line": 41, - "column": 28, + "column": 29, "endLine": 41, - "endColumn": 32, + "endColumn": 33, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -176,9 +176,9 @@ }, { "line": 42, - "column": 36, + "column": 37, "endLine": 42, - "endColumn": 40, + "endColumn": 41, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -598,7 +598,7 @@ "line": 102, "column": 7, "endLine": 102, - "endColumn": 32, + "endColumn": 33, "problem": "DestructuringDeclaration", "suggest": "", "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)", @@ -716,9 +716,9 @@ }, { "line": 117, - "column": 46, + "column": 47, "endLine": 117, - "endColumn": 47, + "endColumn": 48, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", @@ -778,7 +778,7 @@ "line": 126, "column": 10, "endLine": 126, - "endColumn": 34, + "endColumn": 36, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -786,9 +786,9 @@ }, { "line": 126, - "column": 27, + "column": 28, "endLine": 126, - "endColumn": 30, + "endColumn": 31, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -984,6 +984,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 162, "column": 16, @@ -994,6 +1004,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 165, "column": 8, @@ -1004,6 +1024,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 168, + "column": 6, + "endLine": 168, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, { "line": 168, "column": 11, @@ -1086,13 +1116,323 @@ }, { "line": 203, - "column": 5, + "column": 6, "endLine": 203, - "endColumn": 9, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 29, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 38, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 212, + "column": 12, + "endLine": 212, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 39, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 11, + "endLine": 218, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 5, + "endLine": 224, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 9, + "endLine": 224, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 16, + "endLine": 224, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 12, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 24, + "endLine": 225, + "endColumn": 29, "problem": "LimitedVoidType", "suggest": "", "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 25, + "endLine": 226, + "endColumn": 26, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 40, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 229, + "column": 14, + "endLine": 229, + "endColumn": 16, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 231, + "column": 21, + "endLine": 231, + "endColumn": 23, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 47, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 31, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 35, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 44, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 251, + "column": 11, + "endLine": 251, + "endColumn": 15, + "problem": "SwitchExpression", + "suggest": "", + "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "severity": "ERROR" + }, + { + "line": 252, + "column": 10, + "endLine": 252, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 253, + "column": 10, + "endLine": 253, + "endColumn": 11, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 22, + "endLine": 257, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 31, + "endLine": 257, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 260, + "column": 5, + "endLine": 262, + "endColumn": 4, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.autofix.json b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json new file mode 100644 index 0000000000000000000000000000000000000000..fcfeff2dac66bbfedc5c49ec4c7dc9234df6eff7 --- /dev/null +++ b/ets2panda/linter/test/main/limit_void_type.ets.autofix.json @@ -0,0 +1,2192 @@ +{ + "copyright": [ + "Copyright (c) 2025 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." + ], + "result": [ + { + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 666, + "end": 683, + "replacementText": "a: undefined = ((): undefined => { func1(); return undefined; })()", + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 15, + "endLine": 19, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 8, + "endLine": 22, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 749, + "end": 766, + "replacementText": "b: undefined = ((): undefined => { func2(); return undefined; })()", + "line": 22, + "column": 8, + "endLine": 22, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 15, + "endLine": 22, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 835, + "end": 864, + "replacementText": "c: undefined = ((): undefined => { new Demo().method(); return undefined; })()", + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 15, + "endLine": 27, + "endColumn": 34, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 931, + "end": 966, + "replacementText": "d: undefined = ((): undefined => { (function (): void { })(); return undefined; })()", + "line": 29, + "column": 8, + "endLine": 29, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 15, + "endLine": 29, + "endColumn": 40, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 37, + "problem": "FunctionExpression", + "autofix": [ + { + "start": 942, + "end": 963, + "replacementText": "(): void => { }", + "line": 29, + "column": 16, + "endLine": 29, + "endColumn": 37 + } + ], + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 8, + "endLine": 32, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1054, + "end": 1081, + "replacementText": "e: undefined = ((): undefined => { await asyncFunc(); return undefined; })()", + "line": 32, + "column": 8, + "endLine": 32, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 10, + "endLine": 35, + "endColumn": 14, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1157, + "end": 1171, + "replacementText": "f: undefined = ((): undefined => { fn(); return undefined; })()", + "line": 35, + "column": 10, + "endLine": 35, + "endColumn": 14 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 35, + "column": 17, + "endLine": 35, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 8, + "endLine": 39, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1235, + "end": 1260, + "replacementText": "g: undefined = ((): undefined => { func3() as void; return undefined; })()", + "line": 39, + "column": 8, + "endLine": 39, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 39, + "column": 15, + "endLine": 39, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 41, + "column": 29, + "endLine": 41, + "endColumn": 33, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1322, + "end": 1326, + "replacementText": "1000.0", + "line": 41, + "column": 29, + "endLine": 41, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1333, + "end": 1370, + "replacementText": "h: undefined = ((): undefined => { setTimeout(() => { }, 1000); return undefined; })()", + "line": 42, + "column": 8, + "endLine": 42, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 37, + "endLine": 42, + "endColumn": 41, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 1365, + "end": 1369, + "replacementText": "1000.0", + "line": 42, + "column": 37, + "endLine": 42, + "endColumn": 41 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 8, + "endLine": 45, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1451, + "end": 1473, + "replacementText": "i: undefined = ((): undefined => { funcArr[0](); return undefined; })()", + "line": 45, + "column": 8, + "endLine": 45, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 15, + "endLine": 45, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 15, + "endLine": 45, + "endColumn": 25, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 13, + "endLine": 47, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 8, + "endLine": 50, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1551, + "end": 1573, + "replacementText": "j: undefined = ((): undefined => { obj.action(); return undefined; })()", + "line": 50, + "column": 8, + "endLine": 50, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 50, + "column": 15, + "endLine": 50, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 8, + "endLine": 54, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1647, + "end": 1664, + "replacementText": "k: undefined = ((): undefined => { func4(); return undefined; })()", + "line": 54, + "column": 8, + "endLine": 54, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 54, + "column": 15, + "endLine": 54, + "endColumn": 22, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 8, + "endLine": 57, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1740, + "end": 1764, + "replacementText": "l: undefined = ((): undefined => { exportedFunc(); return undefined; })()", + "line": 57, + "column": 8, + "endLine": 57, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 57, + "column": 15, + "endLine": 57, + "endColumn": 29, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 8, + "endLine": 60, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 1838, + "end": 1861, + "replacementText": "m: undefined = ((): undefined => { genericFunc(); return undefined; })()", + "line": 60, + "column": 8, + "endLine": 60, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 15, + "endLine": 60, + "endColumn": 28, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 15, + "endLine": 60, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 1, + "endLine": 62, + "endColumn": 31, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 1, + "endLine": 63, + "endColumn": 42, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 1, + "endLine": 64, + "endColumn": 48, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2024, + "end": 2048, + "replacementText": "n: undefined = ((): undefined => { overloadFunc(); return undefined; })()", + "line": 65, + "column": 8, + "endLine": 65, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 65, + "column": 15, + "endLine": 65, + "endColumn": 29, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 8, + "endLine": 69, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2147, + "end": 2168, + "replacementText": "o: undefined = ((): undefined => { aliasFunc(); return undefined; })()", + "line": 69, + "column": 8, + "endLine": 69, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 69, + "column": 15, + "endLine": 69, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 8, + "endLine": 77, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2300, + "end": 2329, + "replacementText": "p: undefined = ((): undefined => { new Printer().run(); return undefined; })()", + "line": 77, + "column": 8, + "endLine": 77, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 77, + "column": 15, + "endLine": 77, + "endColumn": 34, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 8, + "endLine": 80, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2414, + "end": 2435, + "replacementText": "q: undefined = ((): undefined => { withParam(); return undefined; })()", + "line": 80, + "column": 8, + "endLine": 80, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 80, + "column": 15, + "endLine": 80, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 8, + "endLine": 83, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2513, + "end": 2535, + "replacementText": "r: undefined = ((): undefined => { sum(1, 2, 3); return undefined; })()", + "line": 83, + "column": 8, + "endLine": 83, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 15, + "endLine": 83, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 19, + "endLine": 83, + "endColumn": 20, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2527, + "end": 2528, + "replacementText": "1.0", + "line": 83, + "column": 19, + "endLine": 83, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 22, + "endLine": 83, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2530, + "end": 2531, + "replacementText": "2.0", + "line": 83, + "column": 22, + "endLine": 83, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 83, + "column": 25, + "endLine": 83, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 2533, + "end": 2534, + "replacementText": "3.0", + "line": 83, + "column": 25, + "endLine": 83, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 19, + "endLine": 85, + "endColumn": 23, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 8, + "endLine": 86, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2613, + "end": 2644, + "replacementText": "s: undefined = ((): undefined => { withThis.call(window); return undefined; })()", + "line": 86, + "column": 8, + "endLine": 86, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 24, + "endLine": 86, + "endColumn": 28, + "problem": "FunctionApplyCall", + "suggest": "", + "rule": "'Function.apply', 'Function.call' are not supported (arkts-no-func-apply-call)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 90, + "endColumn": 2, + "problem": "GeneratorFunction", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 3, + "endLine": 89, + "endColumn": 8, + "problem": "YieldExpression", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 8, + "endLine": 91, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2734, + "end": 2766, + "replacementText": "u: undefined = ((): undefined => { genFunc().next().value; return undefined; })()", + "line": 91, + "column": 8, + "endLine": 91, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 15, + "endLine": 91, + "endColumn": 37, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 8, + "endLine": 94, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2842, + "end": 2861, + "replacementText": "w: undefined = ((): undefined => { curry()(); return undefined; })()", + "line": 94, + "column": 8, + "endLine": 94, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 94, + "column": 15, + "endLine": 94, + "endColumn": 24, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 12, + "endLine": 97, + "endColumn": 16, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 8, + "endLine": 100, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 2966, + "end": 3002, + "replacementText": "x: undefined = ((): undefined => { new Chain().first().last(); return undefined; })()", + "line": 100, + "column": 8, + "endLine": 100, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 100, + "column": 15, + "endLine": 100, + "endColumn": 41, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 102, + "column": 7, + "endLine": 102, + "endColumn": 33, + "problem": "DestructuringDeclaration", + "autofix": [ + { + "replacementText": "GeneratedDestructArray_1", + "start": 3050, + "end": 3056, + "line": 102, + "column": 7, + "endLine": 102, + "endColumn": 33 + }, + { + "replacementText": "\nconst func = GeneratedDestructArray_1[0];\n", + "start": 3077, + "end": 3077, + "line": 102, + "column": 7, + "endLine": 102, + "endColumn": 33 + } + ], + "suggest": "", + "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 8, + "endLine": 103, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3082, + "end": 3098, + "replacementText": "y: undefined = ((): undefined => { func(); return undefined; })()", + "line": 103, + "column": 8, + "endLine": 103, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 15, + "endLine": 103, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 105, + "column": 19, + "endLine": 105, + "endColumn": 20, + "problem": "ObjectTypeLiteral", + "autofix": [ + { + "start": 3128, + "end": 3159, + "replacementText": "interface Wrapper {\n value: T;\n}", + "line": 105, + "column": 19, + "endLine": 105, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Object literals cannot be used as type declarations (arkts-no-obj-literals-as-types)", + "severity": "ERROR" + }, + { + "line": 106, + "column": 38, + "endLine": 106, + "endColumn": 39, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 8, + "endLine": 107, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3223, + "end": 3248, + "replacementText": "z: undefined = ((): undefined => { wrapped.value(); return undefined; })()", + "line": 107, + "column": 8, + "endLine": 107, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 107, + "column": 15, + "endLine": 107, + "endColumn": 30, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 109, + "column": 23, + "endLine": 109, + "endColumn": 61, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 9, + "endLine": 111, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3398, + "end": 3419, + "replacementText": "aa: undefined = ((): undefined => { condFunc(); return undefined; })()", + "line": 111, + "column": 9, + "endLine": 111, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 111, + "column": 16, + "endLine": 111, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 114, + "column": 3, + "endLine": 114, + "endColumn": 12, + "problem": "CallSignature", + "suggest": "", + "rule": "Use \"class\" instead of a type with call signature (arkts-no-call-signatures)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 29, + "endLine": 117, + "endColumn": 35, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 117, + "column": 47, + "endLine": 117, + "endColumn": 48, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 9, + "endLine": 118, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3560, + "end": 3578, + "replacementText": "ab: undefined = ((): undefined => { mixed(); return undefined; })()", + "line": 118, + "column": 9, + "endLine": 118, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 16, + "endLine": 118, + "endColumn": 23, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 10, + "endLine": 121, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 9, + "endLine": 123, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3667, + "end": 3689, + "replacementText": "ac: undefined = ((): undefined => { recursive(); return undefined; })()", + "line": 123, + "column": 9, + "endLine": 123, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 123, + "column": 16, + "endLine": 123, + "endColumn": 27, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 10, + "endLine": 126, + "endColumn": 36, + "problem": "FunctionExpression", + "autofix": [ + { + "start": 3757, + "end": 3783, + "replacementText": "(target: any) => { }", + "line": 126, + "column": 10, + "endLine": 126, + "endColumn": 36 + } + ], + "suggest": "", + "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", + "severity": "ERROR" + }, + { + "line": 126, + "column": 28, + "endLine": 126, + "endColumn": 31, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 128, + "column": 1, + "endLine": 128, + "endColumn": 13, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 9, + "endLine": 130, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3824, + "end": 3857, + "replacementText": "ad: undefined = ((): undefined => { decorator()(Decorated); return undefined; })()", + "line": 130, + "column": 9, + "endLine": 130, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 16, + "endLine": 130, + "endColumn": 38, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 28, + "endLine": 130, + "endColumn": 37, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 10, + "endLine": 134, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 136, + "column": 6, + "endLine": 136, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 9, + "endLine": 138, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 3981, + "end": 3989, + "replacementText": "a2: undefined = undefined", + "line": 138, + "column": 9, + "endLine": 138, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 9, + "endLine": 140, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 19, + "endLine": 140, + "endColumn": 23, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 142, + "column": 7, + "endLine": 142, + "endColumn": 11, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 1, + "endLine": 144, + "endColumn": 6, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 9, + "endLine": 144, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 9, + "endLine": 146, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4199, + "end": 4214, + "replacementText": "a4: undefined = ((): undefined => { f1(); return undefined; })()", + "line": 146, + "column": 9, + "endLine": 146, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 16, + "endLine": 146, + "endColumn": 20, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 16, + "endLine": 148, + "endColumn": 20, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4271, + "end": 4278, + "replacementText": "a: undefined", + "line": 148, + "column": 16, + "endLine": 148, + "endColumn": 20 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 150, + "column": 4, + "endLine": 150, + "endColumn": 8, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 153, + "column": 6, + "endLine": 153, + "endColumn": 10, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4382, + "end": 4390, + "replacementText": "f: undefined = undefined;", + "line": 153, + "column": 6, + "endLine": 153, + "endColumn": 10 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 155, + "column": 8, + "endLine": 155, + "endColumn": 12, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4438, + "end": 4445, + "replacementText": "p: undefined", + "line": 155, + "column": 8, + "endLine": 155, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 157, + "column": 18, + "endLine": 157, + "endColumn": 22, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4508, + "end": 4515, + "replacementText": "a: undefined", + "line": 157, + "column": 18, + "endLine": 157, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4599, + "end": 4619, + "replacementText": "undefined | Promise", + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36 + }, + { + "start": 4622, + "end": 4622, + "replacementText": "\nreturn undefined;\n", + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 36 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 162, + "column": 16, + "endLine": 162, + "endColumn": 20, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 4686, + "end": 4699, + "replacementText": "undefined | number", + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21 + }, + { + "start": 4702, + "end": 4702, + "replacementText": "\nreturn undefined;\n", + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 165, + "column": 8, + "endLine": 165, + "endColumn": 12, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 168, + "column": 6, + "endLine": 168, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 168, + "column": 11, + "endLine": 168, + "endColumn": 15, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 169, + "column": 12, + "endLine": 169, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 174, + "column": 22, + "endLine": 174, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 197, + "column": 23, + "endLine": 197, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 197, + "column": 31, + "endLine": 197, + "endColumn": 36, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 200, + "column": 5, + "endLine": 200, + "endColumn": 7, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 201, + "column": 19, + "endLine": 201, + "endColumn": 24, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 201, + "column": 27, + "endLine": 201, + "endColumn": 32, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 203, + "column": 6, + "endLine": 203, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 29, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5432, + "end": 5445, + "replacementText": "string | undefined", + "line": 211, + "column": 29, + "endLine": 211, + "endColumn": 42 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 38, + "endLine": 211, + "endColumn": 42, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 212, + "column": 12, + "endLine": 212, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5459, + "end": 5460, + "replacementText": "0.0", + "line": 212, + "column": 12, + "endLine": 212, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5521, + "end": 5534, + "replacementText": "string | undefined", + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43 + }, + { + "start": 5556, + "end": 5563, + "replacementText": "return undefined;", + "line": 217, + "column": 30, + "endLine": 217, + "endColumn": 43 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 217, + "column": 39, + "endLine": 217, + "endColumn": 43, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 218, + "column": 11, + "endLine": 218, + "endColumn": 12, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5547, + "end": 5548, + "replacementText": "0.0", + "line": 218, + "column": 11, + "endLine": 218, + "endColumn": 12 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 5, + "endLine": 224, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 9, + "endLine": 224, + "endColumn": 13, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5621, + "end": 5637, + "replacementText": "ss: undefined = ((): undefined => { foo(); return undefined; })()", + "line": 224, + "column": 9, + "endLine": 224, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 224, + "column": 16, + "endLine": 224, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 21, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5642, + "end": 5666, + "replacementText": "t: undefined | number = ((): undefined | number => { foo(); return undefined; })()", + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 21 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 8, + "endLine": 225, + "endColumn": 12, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 225, + "column": 24, + "endLine": 225, + "endColumn": 29, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 22, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5671, + "end": 5692, + "replacementText": "t2: undefined | number = ((): undefined | number => { 1; return undefined; })()", + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 22 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 9, + "endLine": 226, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 226, + "column": 25, + "endLine": 226, + "endColumn": 26, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5691, + "end": 5692, + "replacementText": "1.0", + "line": 226, + "column": 25, + "endLine": 226, + "endColumn": 26 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5725, + "end": 5738, + "replacementText": "string | undefined", + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44 + }, + { + "start": 5764, + "end": 5771, + "replacementText": "return undefined;", + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44 + }, + { + "start": 5842, + "end": 5849, + "replacementText": "return undefined;", + "line": 228, + "column": 31, + "endLine": 228, + "endColumn": 44 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 228, + "column": 40, + "endLine": 228, + "endColumn": 44, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 229, + "column": 14, + "endLine": 229, + "endColumn": 16, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5754, + "end": 5756, + "replacementText": "12.0", + "line": 229, + "column": 14, + "endLine": 229, + "endColumn": 16 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 231, + "column": 21, + "endLine": 231, + "endColumn": 23, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5792, + "end": 5794, + "replacementText": "18.0", + "line": 231, + "column": 21, + "endLine": 231, + "endColumn": 23 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 5894, + "end": 5907, + "replacementText": "string | undefined", + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51 + }, + { + "start": 5989, + "end": 5996, + "replacementText": "return undefined;", + "line": 238, + "column": 38, + "endLine": 238, + "endColumn": 51 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 47, + "endLine": 238, + "endColumn": 51, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 6021, + "end": 6034, + "replacementText": "string | undefined", + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35 + }, + { + "start": 6062, + "end": 6062, + "replacementText": "\nreturn undefined;\n", + "line": 246, + "column": 22, + "endLine": 246, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 246, + "column": 31, + "endLine": 246, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 35, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 6099, + "end": 6112, + "replacementText": "string | undefined", + "line": 250, + "column": 35, + "endLine": 250, + "endColumn": 48 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 250, + "column": 44, + "endLine": 250, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 251, + "column": 11, + "endLine": 251, + "endColumn": 15, + "problem": "SwitchExpression", + "suggest": "", + "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "severity": "ERROR" + }, + { + "line": 252, + "column": 10, + "endLine": 252, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 6142, + "end": 6143, + "replacementText": "1.0", + "line": 252, + "column": 10, + "endLine": 252, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 253, + "column": 10, + "endLine": 253, + "endColumn": 11, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 6167, + "end": 6168, + "replacementText": "2.0", + "line": 253, + "column": 10, + "endLine": 253, + "endColumn": 11 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 22, + "endLine": 257, + "endColumn": 35, + "problem": "LimitedVoidType", + "autofix": [ + { + "start": 6216, + "end": 6229, + "replacementText": "string | undefined", + "line": 257, + "column": 22, + "endLine": 257, + "endColumn": 35 + } + ], + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 257, + "column": 31, + "endLine": 257, + "endColumn": 35, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 260, + "column": 5, + "endLine": 262, + "endColumn": 4, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.json b/ets2panda/linter/test/main/limit_void_type.ets.json index c23430e5d2f182b83a08ba6b9c9c8445030b3948..1e0934e13b4d8af69357c031cfc4004d958a4efb 100644 --- a/ets2panda/linter/test/main/limit_void_type.ets.json +++ b/ets2panda/linter/test/main/limit_void_type.ets.json @@ -18,7 +18,7 @@ "line": 29, "column": 16, "endLine": 29, - "endColumn": 35, + "endColumn": 37, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -88,7 +88,7 @@ "line": 102, "column": 7, "endLine": 102, - "endColumn": 32, + "endColumn": 33, "problem": "DestructuringDeclaration", "suggest": "", "rule": "Destructuring variable declarations are not supported (arkts-no-destruct-decls)", @@ -138,7 +138,7 @@ "line": 117, "column": 22, "endLine": 117, - "endColumn": 59, + "endColumn": 60, "problem": "LimitedStdLibApi", "suggest": "", "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", @@ -146,9 +146,9 @@ }, { "line": 117, - "column": 46, + "column": 47, "endLine": 117, - "endColumn": 47, + "endColumn": 48, "problem": "ObjectLiteralNoContextType", "suggest": "", "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", @@ -158,7 +158,7 @@ "line": 126, "column": 10, "endLine": 126, - "endColumn": 34, + "endColumn": 36, "problem": "FunctionExpression", "suggest": "", "rule": "Use arrow functions instead of function expressions (arkts-no-func-expressions)", @@ -166,9 +166,9 @@ }, { "line": 126, - "column": 27, + "column": 28, "endLine": 126, - "endColumn": 30, + "endColumn": 31, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", @@ -184,6 +184,16 @@ "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", "severity": "WARNING" }, + { + "line": 168, + "column": 6, + "endLine": 168, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, { "line": 200, "column": 5, @@ -193,6 +203,16 @@ "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" + }, + { + "line": 224, + "column": 5, + "endLine": 224, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" } ] } \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets b/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets new file mode 100644 index 0000000000000000000000000000000000000000..8873cd3602a4a575d3975580afa61e9e65bab695 --- /dev/null +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.ets @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2025 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. + */ + + +// Example 1: Basic function +function func1(): void { } +let a: undefined = ((): undefined => { func1(); return undefined; })(); +// Example 2: Arrow function +const func2 = (): void => { }; +let b: undefined = ((): undefined => { func2(); return undefined; })(); +// Example 3: Class method +class Demo { + method(): void { } +} +let c: undefined = ((): undefined => { new Demo().method(); return undefined; })(); +// Example 4: Immediately Invoked Function Expression (IIFE) +let d: undefined = ((): undefined => { ((): void => { })(); return undefined; })(); +// Example 5: Asynchronous function +async function asyncFunc(): Promise { } +let e: undefined = ((): undefined => { await asyncFunc(); return undefined; })(); +// Example 6: Function parameter +function wrapper(fn: () => void) { + let f: undefined = ((): undefined => { fn(); return undefined; })(); +} +// Example 7: Type assertion +function func3(): void { } +let g: undefined = ((): undefined => { func3() as void; return undefined; })(); +// Example 8: Callback function +setTimeout((): void => { }, 1000.0); +let h: undefined = ((): undefined => { setTimeout(() => { }, 1000.0); return undefined; })(); +// Example 9: Array operation +const funcArr: (() => void)[] = [() => { }]; +let i: undefined = ((): undefined => { funcArr[0](); return undefined; })(); +// Example 10: Object method +const obj = { + action: (): void => { } +}; +let j: undefined = ((): undefined => { obj.action(); return undefined; })(); +// Example 11: Strict mode +// @ts-strict +function func4(): void { } +let k: undefined = ((): undefined => { func4(); return undefined; })(); +// Example 12: Module export +export function exportedFunc(): void { } +let l: undefined = ((): undefined => { exportedFunc(); return undefined; })(); +// Example 13: Generic function +function genericFunc(): void { } +let m: undefined = ((): undefined => { genericFunc(); return undefined; })(); +// Example 14: Function overloading +function overloadFunc(): void; +function overloadFunc(n: number): number; +function overloadFunc(n?: number) { return n; } +let n: undefined = ((): undefined => { overloadFunc(); return undefined; })(); +// Example 15: Type alias +type VoidFunc = () => void; +const aliasFunc: VoidFunc = () => { }; +let o: undefined = ((): undefined => { aliasFunc(); return undefined; })(); +// Example 16: Interface implementation +interface Task { + run(): void; +} +class Printer implements Task { + run(): void { } +} +let p: undefined = ((): undefined => { new Printer().run(); return undefined; })(); +// Example 17: Optional parameter +function withParam(param?: string): void { } +let q: undefined = ((): undefined => { withParam(); return undefined; })(); +// Example 18: Rest parameter +function sum(...nums: number[]): void { } +let r: undefined = ((): undefined => { sum(1.0, 2.0, 3.0); return undefined; })(); +// Example 19: This parameter +function withThis(this: Window): void { } +let s: undefined = ((): undefined => { withThis.call(window); return undefined; })(); +// Example 20: Generator function +function* genFunc(): Generator { + yield; +} +let u: undefined = ((): undefined => { genFunc().next().value; return undefined; })(); +// Example 21: Function currying +const curry = () => (): void => { }; +let w: undefined = ((): undefined => { curry()(); return undefined; })(); +// Example 22: Method chaining +class Chain { + first(): this { return this; } + last(): void { } +} +let x: undefined = ((): undefined => { new Chain().first().last(); return undefined; })(); +// Example 23: Destructuring assignment +const GeneratedDestructArray_1 = [(): void => { }]; +const func = GeneratedDestructArray_1[0]; + +let y: undefined = ((): undefined => { func(); return undefined; })(); +// Example 24: Type mapping +interface Wrapper { + value: T; +} +const wrapped: Wrapper<() => void> = { value: () => { } }; +let z: undefined = ((): undefined => { wrapped.value(); return undefined; })(); +// Example 25: Conditional type +type Conditional = T extends boolean ? () => void : never; +const condFunc: Conditional = () => { }; +let aa: undefined = ((): undefined => { condFunc(); return undefined; })(); +// Example 26: Mixed type +interface Mixed { + (): void; + prop: string; +} +const mixed: Mixed = Object.assign(() => { }, { prop: "" }); +let ab: undefined = ((): undefined => { mixed(); return undefined; })(); +// Example 27: Recursive call +function recursive(): void { + return recursive(); +} +let ac: undefined = ((): undefined => { recursive(); return undefined; })(); +// Example 28: Decorator function +function decorator() { + return (target: any) => { }; +} +@decorator() +class Decorated { } +let ad: undefined = ((): undefined => { decorator()(Decorated); return undefined; })(); + +function f1(): void { } + +let a1 = f1(); // type `void` is used as value + +a1 = f1(); // type `void` is used as value + +let a2: undefined = undefined; // type `void` is used as type annotation + +let a3: void[] = [f1()]; // type `void` is used as type annotation + +a3 = [f1()]; // type `void` is used as value + +a3[0] = f1(); // type `void` is used as value + +let a4: undefined = ((): undefined => { f1(); return undefined; })(); // type `void` is used as type annotation + +function f2(a: undefined) { } // type `void` is used as type annotation + +f2(f1()); // type `void` is used as value + +class A { + f: undefined = undefined; // type `void` is used as type annotation + + m(p: undefined) { } // type `void` is used as type annotation + + constructor(a: undefined) { // type `void` is used as type annotation + this.f = a; + } +} + +function f3(): undefined | Promise { +return undefined; +} // type `void` is not allowed in union type + +class B { + m(): undefined | number { +return undefined; +} // type `void` is not allowed in union type +} + +type ss = void; +let sspar: ss; + +type ff = string; +let ffpar: ff; + +let sread: readonly [void] = [undefined]; + +interface BT { + qaq: Function; +} + +class C { + private cc?: BT; + + private d(): void { + this.cc = { + qaq: (caller?: string): void => this.qaqq(caller) + } + } + private qaqq(caller?: string): void { + return; + } +} + +function foo(): void { } +function bar(): void { } + +let aa = '1'; +let bb = aa === '1' ? foo() : bar(); // Error + +aa === '1' ? foo() : bar(); // No error +let dd; +dd = aa === '1' ? foo() : bar(); // Error +interface testB { + u: void; // Error + fooIf(): void; +} + +function foo1():void{ + return foo(); // No Error +} + +function foocfe(a: number): string | undefined { + if (a >= 0.0) { + return "a >= 0"; + } +} + +function foocfe2(a: number): string | undefined { + if (a < 0.0) { + return undefined; + } + return "a >= 0"; +} +function fooefc(): void { } +let ss: undefined = ((): undefined => { foo(); return undefined; })() +let t: undefined | number = ((): undefined | number => { foo(); return undefined; })() +let t2: undefined | number = ((): undefined | number => { 1.0; return undefined; })(); + +function greet(hour: number): string | undefined { + if (hour < 12.0) { + return undefined; + } else if (hour < 18.0) { + return "Good afternoon"; + } else { + return undefined; + } +} + +function logOrReturn(flag: boolean): string | undefined { + if (flag) { + return "Flag is true"; + } + console.log("Flag is false"); + return undefined; +} + +function justLogs(): string | undefined { + console.log("Hello!"); + +return undefined; +} + +function getStatus(code: number): string | undefined { + switch (code) { + case 1.0: return "OK"; + case 2.0: return "Warning"; + } +} + +function tryThing(): string | undefined { + try { + return "Worked!"; + } catch (e) { + console.error(e); + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/limit_void_type.ets.migrate.json b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json new file mode 100644 index 0000000000000000000000000000000000000000..74d51ae8db6be6ac8cc4ccb9c338f87680269510 --- /dev/null +++ b/ets2panda/linter/test/main/limit_void_type.ets.migrate.json @@ -0,0 +1,478 @@ +{ + "copyright": [ + "Copyright (c) 2025 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." + ], + "result": [ + { + "line": 39, + "column": 40, + "endLine": 39, + "endColumn": 47, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 45, + "column": 40, + "endLine": 45, + "endColumn": 50, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 47, + "column": 13, + "endLine": 47, + "endColumn": 14, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 60, + "column": 40, + "endLine": 60, + "endColumn": 53, + "problem": "GenericCallNoTypeArgs", + "suggest": "", + "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", + "severity": "ERROR" + }, + { + "line": 62, + "column": 1, + "endLine": 62, + "endColumn": 31, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 63, + "column": 1, + "endLine": 63, + "endColumn": 42, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 64, + "column": 1, + "endLine": 64, + "endColumn": 48, + "problem": "TsOverload", + "suggest": "", + "rule": "Class TS overloading is not supported(arkts-no-ts-overload)", + "severity": "ERROR" + }, + { + "line": 85, + "column": 19, + "endLine": 85, + "endColumn": 23, + "problem": "InvalidIdentifier", + "suggest": "", + "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "severity": "ERROR" + }, + { + "line": 86, + "column": 49, + "endLine": 86, + "endColumn": 53, + "problem": "FunctionApplyCall", + "suggest": "", + "rule": "'Function.apply', 'Function.call' are not supported (arkts-no-func-apply-call)", + "severity": "ERROR" + }, + { + "line": 88, + "column": 1, + "endLine": 90, + "endColumn": 2, + "problem": "GeneratorFunction", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 89, + "column": 3, + "endLine": 89, + "endColumn": 8, + "problem": "YieldExpression", + "suggest": "", + "rule": "Generator functions are not supported (arkts-no-generators)", + "severity": "ERROR" + }, + { + "line": 91, + "column": 40, + "endLine": 91, + "endColumn": 62, + "problem": "AvoidUnionTypes", + "suggest": "", + "rule": "Avoid using union types (arkts-common-union-member-access)", + "severity": "ERROR" + }, + { + "line": 97, + "column": 12, + "endLine": 97, + "endColumn": 16, + "problem": "ThisType", + "suggest": "", + "rule": "Type notation using \"this\" is not supported (arkts-no-typing-with-this)", + "severity": "ERROR" + }, + { + "line": 103, + "column": 14, + "endLine": 103, + "endColumn": 41, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 113, + "column": 23, + "endLine": 113, + "endColumn": 61, + "problem": "ConditionalType", + "suggest": "", + "rule": "Conditional types are not supported (arkts-no-conditional-types)", + "severity": "ERROR" + }, + { + "line": 118, + "column": 3, + "endLine": 118, + "endColumn": 12, + "problem": "CallSignature", + "suggest": "", + "rule": "Use \"class\" instead of a type with call signature (arkts-no-call-signatures)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 29, + "endLine": 121, + "endColumn": 35, + "problem": "LimitedStdLibApi", + "suggest": "", + "rule": "Usage of standard library is restricted (arkts-limited-stdlib)", + "severity": "ERROR" + }, + { + "line": 121, + "column": 47, + "endLine": 121, + "endColumn": 48, + "problem": "ObjectLiteralNoContextType", + "suggest": "", + "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", + "severity": "ERROR" + }, + { + "line": 125, + "column": 10, + "endLine": 125, + "endColumn": 21, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 130, + "column": 19, + "endLine": 130, + "endColumn": 22, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 132, + "column": 1, + "endLine": 132, + "endColumn": 13, + "problem": "DecoratorsNotSupported", + "suggest": "", + "rule": "Decorators are not supported(arkts-no-ts-decorators)", + "severity": "ERROR" + }, + { + "line": 134, + "column": 53, + "endLine": 134, + "endColumn": 62, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 138, + "column": 10, + "endLine": 138, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 140, + "column": 6, + "endLine": 140, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 9, + "endLine": 144, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 144, + "column": 19, + "endLine": 144, + "endColumn": 23, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 146, + "column": 7, + "endLine": 146, + "endColumn": 11, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 1, + "endLine": 148, + "endColumn": 6, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 148, + "column": 9, + "endLine": 148, + "endColumn": 13, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 154, + "column": 4, + "endLine": 154, + "endColumn": 8, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 6, + "endLine": 176, + "endColumn": 8, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 176, + "column": 11, + "endLine": 176, + "endColumn": 15, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 177, + "column": 12, + "endLine": 177, + "endColumn": 14, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 182, + "column": 22, + "endLine": 182, + "endColumn": 26, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 205, + "column": 23, + "endLine": 205, + "endColumn": 28, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 205, + "column": 31, + "endLine": 205, + "endColumn": 36, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 208, + "column": 5, + "endLine": 208, + "endColumn": 7, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 209, + "column": 19, + "endLine": 209, + "endColumn": 24, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 209, + "column": 27, + "endLine": 209, + "endColumn": 32, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 211, + "column": 6, + "endLine": 211, + "endColumn": 10, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, + { + "line": 232, + "column": 5, + "endLine": 232, + "endColumn": 7, + "problem": "DeclWithDuplicateName", + "suggest": "", + "rule": "Use unique names for types and namespaces. (arkts-unique-names)", + "severity": "ERROR" + }, + { + "line": 261, + "column": 11, + "endLine": 261, + "endColumn": 15, + "problem": "SwitchExpression", + "suggest": "", + "rule": "The switch expression type must be of type char, byte, short, int, long, string or enum (arkts-switch-expr)", + "severity": "ERROR" + }, + { + "line": 270, + "column": 5, + "endLine": 272, + "endColumn": 4, + "problem": "TsLikeCatchType", + "suggest": "", + "rule": "TS catch type are not supported (arkts-no-ts-like-catch-type)", + "severity": "ERROR" + }, + { + "line": 219, + "column": 29, + "endLine": 219, + "endColumn": 47, + "problem": "StrictDiagnostic", + "suggest": "Not all code paths return a value.", + "rule": "Not all code paths return a value.", + "severity": "ERROR" + }, + { + "line": 260, + "column": 35, + "endLine": 260, + "endColumn": 53, + "problem": "StrictDiagnostic", + "suggest": "Not all code paths return a value.", + "rule": "Not all code paths return a value.", + "severity": "ERROR" + }, + { + "line": 267, + "column": 22, + "endLine": 267, + "endColumn": 40, + "problem": "StrictDiagnostic", + "suggest": "Not all code paths return a value.", + "rule": "Not all code paths return a value.", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json index d6b0d31865a62a09f14a7eec9668c73ea66a3172..5b7d055ce4855c051b014955fdd6df71123e3162 100644 --- a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk.ets.arkts2.json @@ -44,6 +44,16 @@ "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", "severity": "ERROR" }, + { + "line": 22, + "column": 26, + "endLine": 22, + "endColumn": 46, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 22, "column": 26, @@ -54,6 +64,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 41, + "column": 28, + "endLine": 41, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 41, "column": 28, @@ -64,6 +84,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 45, + "column": 29, + "endLine": 45, + "endColumn": 49, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 45, "column": 29, diff --git a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json index 5b41bb7baa2ffce5dba97d60b7e91be608ad92c4..9cd15d7313e4e8e3f0cf526ddf2f88a173c0ffb3 100644 --- a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk2.ets.arkts2.json @@ -94,6 +94,16 @@ "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", "severity": "ERROR" }, + { + "line": 28, + "column": 28, + "endLine": 28, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 28, "column": 28, @@ -104,6 +114,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 32, + "column": 26, + "endLine": 32, + "endColumn": 46, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 32, "column": 26, diff --git a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json index 5d0e2d9cb631c646033d268395725ece2391e0d6..80a325be85cda47664b5508927d181f6feee3cf6 100644 --- a/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/limit_void_type_sdk3.ets.arkts2.json @@ -94,6 +94,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 37, + "column": 28, + "endLine": 37, + "endColumn": 48, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 37, "column": 28, @@ -104,6 +114,16 @@ "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", "severity": "ERROR" }, + { + "line": 41, + "column": 26, + "endLine": 41, + "endColumn": 46, + "problem": "LimitedVoidType", + "suggest": "", + "rule": "Type \"void\" has no instances.(arkts-limited-void-type)", + "severity": "ERROR" + }, { "line": 41, "column": 26,