diff --git a/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts b/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts index 6ac2dc88c441d437caea911ff11582b8856bcd76..140b4e81e349c9258aa046ba8f27d1e58e1d3788 100644 --- a/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts +++ b/ets2panda/linter/homecheck/src/checker/migration/InteropAssignCheck.ts @@ -29,6 +29,10 @@ import { ArkNamespace, PrimitiveType, UnclearReferenceType, + AnyType, + UnionType, + NullType, + UndefinedType, } from 'arkanalyzer/lib'; import Logger, { LOG_MODULE_TYPE } from 'arkanalyzer/lib/utils/logger'; import { BaseChecker, BaseMetaData } from '../BaseChecker'; @@ -101,11 +105,15 @@ export class InteropAssignCheck implements BaseChecker { let hasTargetArg = false; const invoke = cs.getInvokeExpr()!; const csMethod = cs.getCfg().getDeclaringMethod(); - invoke.getArgs().forEach(arg => { + invoke.getArgs().forEach((arg, argIdx) => { const argTy = arg.getType(); if (argTy instanceof PrimitiveType || this.isBoxedType(argTy)) { return; } + const paramTy = invoke.getMethodSignature().getMethodSubSignature().getParameterTypes()[argIdx]; + if (this.isAnyType(paramTy) || this.isESObjectType(paramTy)) { + return; + } const argTyLang = this.getTypeDefinedLang(argTy, scene) ?? csMethod?.getLanguage() ?? Language.UNKNOWN; if (argTyLang === Language.ARKTS1_1) { hasTargetArg = true; @@ -126,6 +134,28 @@ export class InteropAssignCheck implements BaseChecker { }); } + private isAnyType(ty: Type): boolean { + return ty instanceof AnyType || (ty instanceof UnclearReferenceType && ty.getName() === 'Any'); + } + + private isESObjectType(ty: Type): boolean { + if (!(ty instanceof UnionType)) { + return false; + } + const types = ty.getTypes(); + if (types.length !== 3) { + return false; + } + const isObjectTy = (type: Type): boolean => { + return type instanceof ClassType && type.getClassSignature().getClassName() === 'Object'; + }; + return ( + types.find(ty => ty instanceof NullType) !== undefined && + types.find(ty => ty instanceof UndefinedType) !== undefined && + types.find(ty => isObjectTy(ty)) !== undefined + ); + } + private isBoxedType(checkType: Type): boolean { const unclear = checkType instanceof UnclearReferenceType && BOXED_SET.has(checkType.getName()); const cls = checkType instanceof ClassType && BOXED_SET.has(checkType.getClassSignature().getClassName()); diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index 71a854799d04a3b6dee94f3cacf45a2d2eb6e498..0895b24f6670ae11385ac3f42b37140065da714b 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -11,6 +11,7 @@ "arkts-no-globalthis", "arkts-no-func-props", "arkts-no-func-bind", + "arkts-no-function-return-this", "arkts-limited-stdlib", "arkts-no-classes-as-obj", "arkts-obj-literal-props", diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 3bb45e961528c596e583f81579f11229e885b4a5..0e70d46498f7912e48dff3857ddbc2468a70b56b 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -171,7 +171,7 @@ cookBookTag[137] = '"globalThis" is not supported (arkts-no-globalthis)'; cookBookTag[138] = 'Some of utility types are not supported (arkts-no-utility-types)'; cookBookTag[139] = 'Declaring properties on functions is not supported (arkts-no-func-props)'; cookBookTag[140] = '\'Function.bind\' is not supported (arkts-no-func-bind)'; -cookBookTag[141] = ''; +cookBookTag[141] = 'Function("return this") is not supported (arkts-no-function-return-this)'; cookBookTag[142] = '"as const" assertions are not supported (arkts-no-as-const)'; cookBookTag[143] = 'Import assertions are not supported (arkts-no-import-assertions)'; cookBookTag[144] = 'Usage of standard library is restricted (arkts-limited-stdlib)'; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index 3bb5dc8a6bb4522e03b9d6f788a6434b608922ff..2d597631ed599ca9982ba4bd5031bb7dc76973d8 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -100,6 +100,7 @@ faultsAttrs[FaultID.UtilityType] = new FaultAttributes(138); faultsAttrs[FaultID.PropertyDeclOnFunction] = new FaultAttributes(139); faultsAttrs[FaultID.FunctionBind] = new FaultAttributes(140, ProblemSeverity.WARNING); faultsAttrs[FaultID.FunctionBindError] = new FaultAttributes(140); +faultsAttrs[FaultID.NoFunctionReturnThis] = new FaultAttributes(141); faultsAttrs[FaultID.ConstAssertion] = new FaultAttributes(142); faultsAttrs[FaultID.ImportAssertion] = new FaultAttributes(143); faultsAttrs[FaultID.LimitedStdLibApi] = new FaultAttributes(144); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 41781ddb22afa6ed0152d6533660fad626cbfe9a..06a54947859a24d3ca5764102167a9a89f5cd8af 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -92,6 +92,7 @@ faultDesc[FaultID.UtilityType] = 'Standard Utility types'; faultDesc[FaultID.PropertyDeclOnFunction] = 'Property declaration on function'; faultDesc[FaultID.FunctionApplyCall] = 'Invoking methods of function objects'; faultDesc[FaultID.FunctionBind] = faultDesc[FaultID.FunctionBindError] = 'Invoking methods of function objects'; +faultDesc[FaultID.NoFunctionReturnThis] = 'no function return this'; faultDesc[FaultID.ConstAssertion] = '"as const" assertion'; faultDesc[FaultID.ImportAssertion] = 'Import assertion'; faultDesc[FaultID.SpreadOperator] = 'Spread operation'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index a221b6e39e18b0a555d1a05423a3595ff2df177f..81b91693937d40a7db254f2be32515200534b6c7 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -93,6 +93,7 @@ export enum FaultID { FunctionApplyCall, FunctionBind, FunctionBindError, + NoFunctionReturnThis, ConstAssertion, ImportAssertion, SpreadOperator, diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index bc8354d803604501f91418e72860e8e406ec2f73..c16c8cb2810802df707ffa017ada46342b11bbcf 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -25,7 +25,7 @@ import { LIMITED_STANDARD_UTILITY_TYPES, LIMITED_STANDARD_UTILITY_TYPES2 } from './utils/consts/LimitedStandardUtilityTypes'; -import { LIKE_FUNCTION, LIKE_FUNCTION_CONSTRUCTOR } from './utils/consts/LikeFunction'; +import { LIKE_FUNCTION, LIKE_FUNCTION_CONSTRUCTOR, FORBIDDEN_FUNCTION_BODY } from './utils/consts/LikeFunction'; import { METHOD_DECLARATION } from './utils/consts/MethodDeclaration'; import { METHOD_SIGNATURE } from './utils/consts/MethodSignature'; import { OPTIONAL_METHOD } from './utils/consts/OptionalMethod'; @@ -1792,13 +1792,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleDeclarationInferredType(node); this.handleDefiniteAssignmentAssertion(node); this.handleSendableClassProperty(node); - this.checkAssignmentNumericSemanticslyPro(node); + this.checkNumericSemanticsForProperty(node); this.handleInvalidIdentifier(node); this.handleStructPropertyDecl(node); this.handlePropertyDeclarationForProp(node); this.handleSdkGlobalApi(node); this.handleObjectLiteralAssignmentToClass(node); - this.handleNumericPublicStatic(node); } private handleSendableClassProperty(node: ts.PropertyDeclaration): void { @@ -2117,7 +2116,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ); } this.handleTSOverload(tsFunctionDeclaration); - this.checkAssignmentNumericSemanticsFuntion(tsFunctionDeclaration); + this.checkNumericSemanticsForFunction(tsFunctionDeclaration); this.handleInvalidIdentifier(tsFunctionDeclaration); this.checkDefaultParamBeforeRequired(tsFunctionDeclaration); this.handleLimitedVoidFunction(tsFunctionDeclaration); @@ -2348,36 +2347,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleAssignmentNotsLikeSmartType(tsBinaryExpr); } - private handleNumericPublicStatic(node: ts.PropertyDeclaration): void { - if (!this.options.arkts2) { - return; - } - if (node.type) { - return; - } - const modifiers = ts.getModifiers(node); - const isTargetProperty = !!modifiers?.length; - if (!isTargetProperty) { - return; - } - if (node.initializer) { - if (ts.isBinaryExpression(node.initializer) && this.isNumericExpression(node.initializer)) { - const autofix = this.autofixer?.fixNumericPublicStatic(node); - this.incrementCounters(node, FaultID.NumericSemantics, autofix); - } - } - } - - private isNumericExpression(node: ts.Node): boolean { - if (ts.isNumericLiteral(node)) { - return true; - } - if (!ts.isBinaryExpression(node)) { - return false; - } - return this.isNumericExpression(node.left) && this.isNumericExpression(node.right); - } - private checkInterOpImportJsDataCompare(expr: ts.BinaryExpression): void { if (!this.useStatic || !this.options.arkts2 || !TypeScriptLinter.isComparisonOperator(expr.operatorToken.kind)) { return; @@ -2517,7 +2486,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkAssignmentNumericSemanticsly(node: ts.VariableDeclaration): void { + private checkNumericSemanticsForVariable(node: ts.VariableDeclaration): void { if (!this.options.arkts2) { return; } @@ -2546,57 +2515,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, name); - const typeText = this.tsTypeChecker.typeToString(type); - const isEnum = this.isNumericEnumType(type); - if (TsUtils.isNumberLike(type, typeText, isEnum)) { - const autofix = this.autofixer?.fixVariableDeclaration(node, isEnum); + if (this.tsUtils.isNumberLike(type)) { + const autofix = this.autofixer?.fixNumericSemanticsForDeclaration(node, type); this.incrementCounters(node, FaultID.NumericSemantics, autofix); } } - private isEnumType(type: ts.Type): boolean { - if (type.flags & ts.TypeFlags.Enum) { - return true; - } - - if (type.symbol?.flags & ts.SymbolFlags.Enum) { - return true; - } - - if (type.flags & ts.TypeFlags.EnumLiteral) { - return true; - } - - if (type.isUnion()) { - return type.types.some((t) => { - return this.isEnumType(t); - }); - } - return false; - } - - private isNumericEnumType(type: ts.Type): boolean { - if (!this.isEnumType(type)) { - return false; - } - const declarations = type.symbol?.getDeclarations() || []; - const enumMemberDecl = declarations.find(ts.isEnumMember); - if (enumMemberDecl) { - const value = this.tsTypeChecker.getConstantValue(enumMemberDecl); - return typeof value === STRINGLITERAL_NUMBER; - } - - const enumDecl = declarations.find(ts.isEnumDeclaration); - if (enumDecl) { - return enumDecl.members.every((member) => { - const memberType = this.tsTypeChecker.getTypeAtLocation(member.name); - return (memberType.flags & ts.TypeFlags.NumberLike) !== 0; - }); - } - return false; - } - - private checkAssignmentNumericSemanticsFuntion(node: ts.FunctionDeclaration): void { + private checkNumericSemanticsForFunction(node: ts.FunctionDeclaration): void { if (!this.options.arkts2) { return; } @@ -2610,9 +2535,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, param.name); - const typeText = this.tsTypeChecker.typeToString(type); - if (typeText === STRINGLITERAL_NUMBER) { - const autofix = this.autofixer?.fixParameter(param); + if (this.tsUtils.isNumberLike(type)) { + const autofix = this.autofixer?.fixNumericSemanticsForDeclaration(param, type); if (autofix) { this.incrementCounters(node, FaultID.NumericSemantics, autofix); } @@ -2635,7 +2559,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private checkAssignmentNumericSemanticslyPro(node: ts.PropertyDeclaration): void { + private checkNumericSemanticsForProperty(node: ts.PropertyDeclaration): void { if (!this.options.arkts2) { return; } @@ -2649,27 +2573,18 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const isNumberArray = ts.isArrayLiteralExpression(initializer) && TypeScriptLinter.isNumberArray(initializer); const isNumber = !isNumberArray && TypeScriptLinter.isNumericInitializer(initializer); - const sym = this.tsTypeChecker.getSymbolAtLocation(name); - if (!sym) { + if (!isNumber && !isNumberArray) { return; } - if (!isNumber && !isNumberArray) { + const sym = this.tsTypeChecker.getSymbolAtLocation(name); + if (!sym) { return; } - const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, name); - const typeText = this.tsTypeChecker.typeToString(type); - const typeFlags = type.flags; - if (isNumber && (typeText === STRINGLITERAL_NUMBER || (typeFlags & ts.TypeFlags.NumberLiteral) !== 0)) { - const autofix = this.autofixer?.fixPropertyDeclaration(node); - this.incrementCounters(node, FaultID.NumericSemantics, autofix); - } - this.checkAssignmentNumericSemanticsArray(node, isNumberArray); - } - checkAssignmentNumericSemanticsArray(node: ts.PropertyDeclaration, isNumberArray: boolean): void { - if (isNumberArray) { - const autofix = this.autofixer?.fixPropertyDeclarationNumericSemanticsArray(node); + const type = this.tsTypeChecker.getTypeOfSymbolAtLocation(sym, name); + if (this.tsUtils.isNumberLike(type)) { + const autofix = this.autofixer?.fixNumericSemanticsForDeclaration(node, type); this.incrementCounters(node, FaultID.NumericSemantics, autofix); } } @@ -2685,6 +2600,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { ) { return true; } + if ( + ts.isBinaryExpression(node) && + TypeScriptLinter.isNumericInitializer(node.left) && + TypeScriptLinter.isNumericInitializer(node.right) + ) { + return true; + } return false; } @@ -2797,7 +2719,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleDefiniteAssignmentAssertion(tsVarDecl); this.handleLimitedVoidType(tsVarDecl); this.handleInvalidIdentifier(tsVarDecl); - this.checkAssignmentNumericSemanticsly(tsVarDecl); + this.checkNumericSemanticsForVariable(tsVarDecl); this.checkTypeFromSdk(tsVarDecl.type); this.handleObjectLiteralforUnionTypeInterop(tsVarDecl); this.handleObjectLiteralAssignmentToClass(tsVarDecl); @@ -5210,6 +5132,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleObjectLiteralAssignmentToClass(tsCallExpr); this.checkRestrictedAPICall(tsCallExpr); this.handleNoDeprecatedApi(tsCallExpr); + this.handleFunctionReturnThisCall(tsCallExpr); } private handleCallExpressionForUI(node: ts.CallExpression): void { @@ -5288,7 +5211,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { })(); if (isNumberGeneric && !isNumberReturnType) { - const autofix = this.autofixer?.fixAppStorageCallExpression(tsCallExpr); + const autofix = this.autofixer?.fixAppStorageCallExpression(varDecl); this.incrementCounters(tsCallExpr, FaultID.NumericSemantics, autofix); } } @@ -5665,6 +5588,77 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private handleFunctionReturnThisCall(node: ts.CallExpression | ts.NewExpression): void { + if (!this.options.arkts2) { + return; + } + const args = node.arguments; + const isUnsafeCallee = this.checkUnsafeFunctionCalleeName(node.expression); + if (!isUnsafeCallee) { + return; + } + if (!args) { + return; + } + if (args.length === 0) { + return; + } + const isForbidden = this.isForbiddenBodyArgument(args[0]); + if (isForbidden) { + this.incrementCounters(node, FaultID.NoFunctionReturnThis); + } + } + + private isForbiddenBodyArgument(arg: ts.Expression): boolean { + if ((ts.isStringLiteral(arg) || ts.isNoSubstitutionTemplateLiteral(arg)) && arg.text === FORBIDDEN_FUNCTION_BODY) { + return true; + } + + if (ts.isIdentifier(arg)) { + const symbol = this.tsTypeChecker.getSymbolAtLocation(arg); + const decl = symbol?.valueDeclaration; + + if ( + decl && + ts.isVariableDeclaration(decl) && + decl.initializer && + ts.isStringLiteral(decl.initializer) && + decl.initializer.text === FORBIDDEN_FUNCTION_BODY + ) { + return true; + } + } + + return false; + } + + private checkUnsafeFunctionCalleeName(expr: ts.Expression): boolean { + if (ts.isIdentifier(expr) && expr.text === LIKE_FUNCTION) { + return true; + } + + if (ts.isParenthesizedExpression(expr)) { + return this.checkUnsafeFunctionCalleeName(expr.expression); + } + + if (ts.isPropertyAccessExpression(expr)) { + if (expr.name.text === LIKE_FUNCTION) { + return true; + } + return this.checkUnsafeFunctionCalleeName(expr.expression); + } + + if (ts.isCallExpression(expr)) { + return this.checkUnsafeFunctionCalleeName(expr.expression); + } + + if (ts.isBinaryExpression(expr) && expr.operatorToken.kind === ts.SyntaxKind.CommaToken) { + return this.checkUnsafeFunctionCalleeName(expr.right); + } + + return false; + } + private handleStructIdentAndUndefinedInArgs( tsCallOrNewExpr: ts.CallExpression | ts.NewExpression, callSignature: ts.Signature @@ -5909,6 +5903,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSendableGenericTypes(tsNewExpr); this.handleInstantiatedJsObject(tsNewExpr, sym); this.handlePromiseNeedVoidResolve(tsNewExpr); + this.handleFunctionReturnThisCall(tsNewExpr); } handlePromiseNeedVoidResolve(newExpr: ts.NewExpression): void { diff --git a/ets2panda/linter/src/lib/autofixes/Autofixer.ts b/ets2panda/linter/src/lib/autofixes/Autofixer.ts index 52855144625fada6b2e2aa01d860716ed6663a0d..6c0a96ff547a2811936705f49ccca19ffc4b3383 100644 --- a/ets2panda/linter/src/lib/autofixes/Autofixer.ts +++ b/ets2panda/linter/src/lib/autofixes/Autofixer.ts @@ -20,8 +20,8 @@ import { NameGenerator } from '../utils/functions/NameGenerator'; import { isAssignmentOperator } from '../utils/functions/isAssignmentOperator'; import { SymbolCache } from './SymbolCache'; import { SENDABLE_DECORATOR } from '../utils/consts/SendableAPI'; +import { ARKTSUTILS_LOCKS_MEMBER } from '../utils/consts/LimitedStdAPI'; import { DEFAULT_MODULE_NAME, PATH_SEPARATOR, SRC_AND_MAIN } from '../utils/consts/OhmUrl'; -import { STRINGLITERAL_NUMBER, STRINGLITERAL_NUMBER_ARRAY } from '../utils/consts/StringLiteral'; import { DOUBLE_DOLLAR_IDENTIFIER, THIS_IDENTIFIER, @@ -2041,7 +2041,7 @@ export class Autofixer { !objectLiteralExpr.parent.type ) { const text = ': ' + newInterfaceName; - const pos = Autofixer.getDeclarationTypePositionForObjectLiteral(objectLiteralExpr.parent); + const pos = Autofixer.getDeclarationTypePosition(objectLiteralExpr.parent); return { start: pos, end: pos, replacementText: text }; } @@ -2057,7 +2057,7 @@ export class Autofixer { return { start: objectLiteralExpr.getStart(), end: objectLiteralExpr.getEnd(), replacementText: text }; } - private static getDeclarationTypePositionForObjectLiteral( + private static getDeclarationTypePosition( decl: ts.VariableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration ): number { if (ts.isPropertyDeclaration(decl)) { @@ -3373,63 +3373,21 @@ export class Autofixer { return this.printer.printNode(ts.EmitHint.Unspecified, node, this.sourceFile); } - fixVariableDeclaration(node: ts.VariableDeclaration, isEnum: boolean): Autofix[] | undefined { - const initializer = node.initializer; - const name = node.name; - const sym = this.typeChecker.getSymbolAtLocation(name); - if (!sym || !initializer) { - return undefined; - } - ts.setCommentRange(initializer, { pos: -1, end: -1 }); - - const type = this.typeChecker.getTypeOfSymbolAtLocation(sym, name); - const typeText = this.typeChecker.typeToString(type); - const typeFlags = type.flags; - - if (!TsUtils.isNumberLike(type, typeText, isEnum)) { - return undefined; - } - - let typeNode: ts.TypeNode; - if (typeText === STRINGLITERAL_NUMBER || (typeFlags & ts.TypeFlags.NumberLiteral) !== 0 || isEnum) { - typeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - } else if (typeText === STRINGLITERAL_NUMBER_ARRAY) { - typeNode = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)); - } else { - return undefined; - } - - const newVarDecl = ts.factory.createVariableDeclaration(name, undefined, typeNode, initializer); - const parent = node.parent; - if (!ts.isVariableDeclarationList(parent)) { - return undefined; - } - const text = this.printer.printNode(ts.EmitHint.Unspecified, newVarDecl, node.getSourceFile()); - return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; + fixNumericSemanticsForDeclaration( + node: ts.VariableDeclaration | ts.PropertyDeclaration | ts.ParameterDeclaration, + type: ts.Type + ): Autofix[] | undefined { + const typeNode = this.getTypeForNumericSemantics(type); + const text = ': ' + this.printer.printNode(ts.EmitHint.Unspecified, typeNode, node.getSourceFile()); + const pos = Autofixer.getDeclarationTypePosition(node); + return [{ start: pos, end: pos, replacementText: text }]; } - fixPropertyDeclarationNumericSemanticsArray(node: ts.PropertyDeclaration): Autofix[] { - const newProperty = ts.factory.createPropertyDeclaration( - node.modifiers, - node.name, - undefined, - ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)), - node.initializer - ); - - const replacementText = this.nonCommentPrinter.printNode( - ts.EmitHint.Unspecified, - newProperty, - node.getSourceFile() - ); - - return [ - { - start: node.getStart(), - end: node.getEnd(), - replacementText: replacementText - } - ]; + private getTypeForNumericSemantics(type: ts.Type): ts.TypeNode { + if (this.utils.isGenericArrayType(type)) { + return ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword)); + } + return ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); } /** @@ -3617,56 +3575,6 @@ export class Autofixer { return undefined; } - fixParameter(param: ts.ParameterDeclaration): Autofix[] { - const newParam = ts.factory.createParameterDeclaration( - param.modifiers, - param.dotDotDotToken, - param.name, - param.questionToken, - ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - param.initializer - ); - const text = this.printer.printNode(ts.EmitHint.Unspecified, newParam, param.getSourceFile()); - return [ - { - start: param.getStart(), - end: param.getEnd(), - replacementText: text - } - ]; - } - - fixPropertyDeclaration(node: ts.PropertyDeclaration): Autofix[] | undefined { - const initializer = node.initializer; - if (initializer === undefined) { - return undefined; - } - const propType = this.typeChecker.getTypeAtLocation(node); - let propTypeNode: ts.TypeNode; - if (propType.flags & ts.TypeFlags.NumberLike) { - propTypeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - } else { - const inferredTypeNode = this.typeChecker.typeToTypeNode(propType, undefined, ts.NodeBuilderFlags.None); - - if (!inferredTypeNode || !this.utils.isSupportedType(inferredTypeNode)) { - return undefined; - } - propTypeNode = inferredTypeNode; - } - - const questionOrExclamationToken = node.questionToken ?? node.exclamationToken ?? undefined; - const newPropDecl = ts.factory.createPropertyDeclaration( - node.modifiers, - node.name, - questionOrExclamationToken, - propTypeNode, - initializer - ); - - const text = this.nonCommentPrinter.printNode(ts.EmitHint.Unspecified, newPropDecl, node.getSourceFile()); - return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; - } - fixFunctionDeclarationly( callExpr: ts.CallExpression, resolvedTypeArgs: ts.NodeArray @@ -4174,45 +4082,75 @@ export class Autofixer { return undefined; } - // 2) Find the enclosing `new` expression + const className = asyncLockProp.name.getText(); + + // 2a) Handle static method calls on AsyncLock (e.g. AsyncLock.request, AsyncLock.acquire, etc.) + const methodProp = asyncLockProp.parent; + if (ts.isPropertyAccessExpression(methodProp)) { + const methodName = methodProp.name.getText(); + const callExpr = methodProp.parent; + if (!ts.isCallExpression(callExpr)) { + return undefined; + } + + const fixes: Autofix[] = []; + // Type fix for variable declaration, if necessary + const varDecl = Autofixer.findParentVariableDeclaration(callExpr); + const typeFix = varDecl ? this.buildConcurrencyLockTypeFix(varDecl, className) : undefined; + if (typeFix) { + fixes.push(typeFix); + } + + // build AsyncLock.(...) + const fixCall = ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + ts.factory.createIdentifier(className), + ts.factory.createIdentifier(methodName) + ), + undefined, + callExpr.arguments + ); + const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, fixCall, callExpr.getSourceFile()); + fixes.push({ start: callExpr.getStart(), end: callExpr.getEnd(), replacementText }); + return fixes; + } + + // 2b) Handle `new ArkTSUtils.locks.AsyncLock()` const newExpr = asyncLockProp.parent; if (!ts.isNewExpression(newExpr)) { return undefined; } - - const className = asyncLockProp.name.getText(); + // build `new AsyncLock()` const replacement = ts.factory.createNewExpression(ts.factory.createIdentifier(className), undefined, []); const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, replacement, newExpr.getSourceFile()); - return [{ start: newExpr.getStart(), end: newExpr.getEnd(), replacementText }]; } - fixAppStorageCallExpression(callExpr: ts.CallExpression): Autofix[] | undefined { - const varDecl = Autofixer.findParentVariableDeclaration(callExpr); - if (!varDecl || varDecl.type) { + /** + * If the variable declaration has a qualified type `*.locks.ClassName`, build a fix to simplify it to `ClassName`. + */ + private buildConcurrencyLockTypeFix(varDecl: ts.VariableDeclaration, className: string): Autofix | undefined { + const typeNode = varDecl.type; + + if (!typeNode || !ts.isTypeReferenceNode(typeNode) || !ts.isQualifiedName(typeNode.typeName)) { return undefined; } - const updatedVarDecl = ts.factory.updateVariableDeclaration( - varDecl, - varDecl.name, - undefined, - ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword), - varDecl.initializer - ); + const qn = typeNode.typeName; + const left = qn.left; + const right = qn.right; - const replacementText = this.printer.printNode(ts.EmitHint.Unspecified, updatedVarDecl, varDecl.getSourceFile()); + // ensure it's of form *.locks.ClassName + if (ts.isQualifiedName(left) && left.right.text === ARKTSUTILS_LOCKS_MEMBER && right.text === className) { + const simple = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(className), undefined); + const text = this.printer.printNode(ts.EmitHint.Unspecified, simple, varDecl.getSourceFile()); + return { start: typeNode.getStart(), end: typeNode.getEnd(), replacementText: text }; + } - return [ - { - replacementText, - start: varDecl.getStart(), - end: varDecl.getEnd() - } - ]; + return undefined; } - private static findParentVariableDeclaration(node: ts.Node): ts.VariableDeclaration | undefined { + private static findParentVariableDeclaration(node: ts.Node): ts.VariableDeclaration | undefined { while (node) { if (ts.isVariableDeclaration(node)) { return node; @@ -4222,6 +4160,13 @@ export class Autofixer { return undefined; } + fixAppStorageCallExpression(varDecl: ts.VariableDeclaration): Autofix[] | undefined { + const typeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); + const text = ': ' + this.printer.printNode(ts.EmitHint.Unspecified, typeNode, varDecl.getSourceFile()); + const pos = Autofixer.getDeclarationTypePosition(varDecl); + return [{ start: pos, end: pos, replacementText: text }]; + } + private static createVariableForInteropImport( interopProperty: string, symbolName: string, @@ -5295,31 +5240,6 @@ export class Autofixer { return [{ start: node.getStart(), end: node.getEnd(), replacementText: text }]; } - fixNumericPublicStatic(node: ts.PropertyDeclaration): Autofix[] | undefined { - if (!node?.name || node.type) { - return undefined; - } - const typeNode = ts.factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword); - const modifiers = ts.getModifiers(node) || []; - const updatedProperty = ts.factory.updatePropertyDeclaration( - node, - modifiers, - node.name, - node.questionToken, - typeNode, - node.initializer - ); - - const newText = this.printer.printNode(ts.EmitHint.Unspecified, updatedProperty, node.getSourceFile()); - return [ - { - start: node.getStart(), - end: node.getEnd(), - replacementText: newText - } - ]; - } - fixRepeat(stmt: ts.ExpressionStatement): Autofix[] { const newExpr = ts.factory.createCallExpression(ts.factory.createIdentifier(VIRTUAL_SCROLL_IDENTIFIER), undefined, [ ts.factory.createObjectLiteralExpression( diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index 32d8ce57719a075450b3bfe10469ae19d9f4ed8e..738928269d0a778b945d0e0c0b9c49f2cf55b3c8 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -115,12 +115,23 @@ export class TsUtils { return false; } - static isEnumType(tsType: ts.Type): boolean { + static isEnumType(tsType: ts.Type, checkUnion?: boolean): boolean { // when type equals `typeof `, only symbol contains information about it's type. const isEnumSymbol = tsType.symbol && this.isEnum(tsType.symbol); // otherwise, we should analyze flags of the type itself const isEnumType = !!(tsType.flags & ts.TypeFlags.Enum) || !!(tsType.flags & ts.TypeFlags.EnumLiteral); - return isEnumSymbol || isEnumType; + + if (isEnumSymbol || isEnumType) { + return true; + } + + if (checkUnion && tsType.isUnion()) { + return tsType.types.some((t) => { + return TsUtils.isEnumType(t); + }); + } + + return false; } static isEnum(tsSymbol: ts.Symbol): boolean { @@ -3453,17 +3464,39 @@ export class TsUtils { } } - static isNumberLike(type: ts.Type, typeText: string, isEnum: boolean): boolean { + isNumberLike(type: ts.Type): boolean { const typeFlags = type.flags; + const typeText = this.tsTypeChecker.typeToString(type); const isNumberLike = typeText === STRINGLITERAL_NUMBER || typeText === STRINGLITERAL_NUMBER_ARRAY || (typeFlags & ts.TypeFlags.NumberLiteral) !== 0 || - isEnum; + this.isNumericEnumType(type); return isNumberLike; } + isNumericEnumType(type: ts.Type): boolean { + if (!TsUtils.isEnumType(type, true)) { + return false; + } + const declarations = type.symbol?.getDeclarations() || []; + const enumMemberDecl = declarations.find(ts.isEnumMember); + if (enumMemberDecl) { + const value = this.tsTypeChecker.getConstantValue(enumMemberDecl); + return typeof value === STRINGLITERAL_NUMBER; + } + + const enumDecl = declarations.find(ts.isEnumDeclaration); + if (enumDecl) { + return enumDecl.members.every((member) => { + const memberType = this.tsTypeChecker.getTypeAtLocation(member.name); + return (memberType.flags & ts.TypeFlags.NumberLike) !== 0; + }); + } + return false; + } + static getModuleName(node: ts.Node): string | undefined { const currentFilePath = node.getSourceFile().fileName; if (!currentFilePath.includes('src')) { diff --git a/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts b/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts index 38a013ece2d59a515c1962bb37e7041da0a0fa43..1367fd24f22ecab951f3b1b37807b5cdc45644a0 100755 --- a/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts +++ b/ets2panda/linter/src/lib/utils/consts/LikeFunction.ts @@ -16,3 +16,5 @@ export const LIKE_FUNCTION = 'Function'; export const LIKE_FUNCTION_CONSTRUCTOR = 'FunctionConstructor'; + +export const FORBIDDEN_FUNCTION_BODY = 'return this'; diff --git a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json index af236ddbd9ee7ade4f0050759cf591322e71316a..b66ee99fd1e2138ce303809ce29f899724b7fd03 100644 --- a/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json +++ b/ets2panda/linter/test/interop/binary_operation_js_obj.ets.autofix.json @@ -514,9 +514,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 747, - "end": 752, - "replacementText": "x: number = 1", + "start": 748, + "end": 748, + "replacementText": ": number", "line": 29, "column": 5, "endLine": 29, @@ -556,9 +556,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 754, - "end": 759, - "replacementText": "y: number = 2", + "start": 755, + "end": 755, + "replacementText": ": number", "line": 29, "column": 12, "endLine": 29, @@ -691,9 +691,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 822, - "end": 832, - "replacementText": "x2: number = bar.a", + "start": 824, + "end": 824, + "replacementText": ": number", "line": 37, "column": 5, "endLine": 37, @@ -712,9 +712,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 834, - "end": 844, - "replacementText": "y2: number = bar.b", + "start": 836, + "end": 836, + "replacementText": ": number", "line": 37, "column": 17, "endLine": 37, diff --git a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json index 9740ccecdb5c1c4db9305c73019fd3fd1960e556..d54c3071e70236a7f8a86ae847bce7285d7d6636 100644 --- a/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_compare.ets.autofix.json @@ -346,9 +346,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 742, - "end": 747, - "replacementText": "x: number = 1", + "start": 743, + "end": 743, + "replacementText": ": number", "line": 29, "column": 5, "endLine": 29, @@ -388,9 +388,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 749, - "end": 754, - "replacementText": "y: number = 2", + "start": 750, + "end": 750, + "replacementText": ": number", "line": 29, "column": 12, "endLine": 29, @@ -502,9 +502,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 818, - "end": 828, - "replacementText": "x2: number = bar.a", + "start": 820, + "end": 820, + "replacementText": ": number", "line": 37, "column": 5, "endLine": 37, @@ -523,9 +523,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 830, - "end": 840, - "replacementText": "y2: number = bar.b", + "start": 832, + "end": 832, + "replacementText": ": number", "line": 37, "column": 17, "endLine": 37, diff --git a/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json index 1452fdc6b3e8444ed1e7a92bc16b1f4bd111fbbe..f837b56a6af8c56a76cbff4a72278f1cfa20851f 100644 --- a/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_index.ets.autofix.json @@ -228,9 +228,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 801, - "end": 806, - "replacementText": "i: number = 0", + "start": 802, + "end": 802, + "replacementText": ": number", "line": 23, "column": 10, "endLine": 23, @@ -524,4 +524,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json index c4175a21f1e94e44965f5dde24dda0498d62fbc6..702bfa960162802ac8bdef528ddf783aa0079d7d 100644 --- a/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json +++ b/ets2panda/linter/test/interop/interop_import_js_rules.ets.autofix.json @@ -601,9 +601,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1392, - "end": 1397, - "replacementText": "i: number = 0", + "start": 1393, + "end": 1393, + "replacementText": ": number", "line": 52, "column": 10, "endLine": 52, @@ -830,9 +830,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1582, - "end": 1588, - "replacementText": "a: number = 1;", + "start": 1583, + "end": 1583, + "replacementText": ": number", "line": 67, "column": 9, "endLine": 67, @@ -872,9 +872,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1589, - "end": 1594, - "replacementText": "b: number = 2;", + "start": 1590, + "end": 1590, + "replacementText": ": number", "line": 67, "column": 16, "endLine": 67, @@ -914,9 +914,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1595, - "end": 1599, - "replacementText": "c: number = 3;", + "start": 1596, + "end": 1596, + "replacementText": ": number", "line": 67, "column": 22, "endLine": 67, @@ -1156,4 +1156,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json index 8aff28f18833ef33a985c0474e23397bce8bda52..2ca2aebf6a3c14eefaa734154b5dbf4a933beefe 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 639, - "end": 657, - "replacementText": "an_array: number[] = [1, 2, 3]", + "start": 647, + "end": 647, + "replacementText": ": number[]", "line": 17, "column": 7, "endLine": 17, @@ -106,9 +106,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 664, - "end": 683, - "replacementText": "a: number = an_array[index]", + "start": 665, + "end": 665, + "replacementText": ": number", "line": 18, "column": 7, "endLine": 18, @@ -158,9 +158,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 690, - "end": 714, - "replacementText": "a1: number = an_array[index + 1]", + "start": 692, + "end": 692, + "replacementText": ": number", "line": 19, "column": 7, "endLine": 19, @@ -210,9 +210,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 721, - "end": 747, - "replacementText": "a2: number = an_array[index + 1.1]", + "start": 723, + "end": 723, + "replacementText": ": number", "line": 20, "column": 7, "endLine": 20, @@ -262,9 +262,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 754, - "end": 772, - "replacementText": "b: number = an_array[1.23]", + "start": 755, + "end": 755, + "replacementText": ": number", "line": 21, "column": 7, "endLine": 21, @@ -394,9 +394,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 887, - "end": 901, - "replacementText": "g: number = an_array[]", + "start": 888, + "end": 888, + "replacementText": ": number", "line": 26, "column": 7, "endLine": 26, @@ -425,9 +425,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 908, - "end": 925, - "replacementText": "h: number = an_array[12.]", + "start": 909, + "end": 909, + "replacementText": ": number", "line": 27, "column": 7, "endLine": 27, @@ -477,9 +477,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 932, - "end": 950, - "replacementText": "i: number = an_array[12.0]", + "start": 933, + "end": 933, + "replacementText": ": number", "line": 28, "column": 7, "endLine": 28, @@ -529,9 +529,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 957, - "end": 972, - "replacementText": "j: number = an_array[0]", + "start": 958, + "end": 958, + "replacementText": ": number", "line": 29, "column": 7, "endLine": 29, @@ -560,9 +560,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 979, - "end": 1009, - "replacementText": "k: number = an_array[Number.MAX_VALUE]", + "start": 980, + "end": 980, + "replacementText": ": number", "line": 30, "column": 7, "endLine": 30, @@ -612,9 +612,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1016, - "end": 1046, - "replacementText": "l: number = an_array[Number.MIN_VALUE]", + "start": 1017, + "end": 1017, + "replacementText": ": number", "line": 31, "column": 7, "endLine": 31, @@ -664,9 +664,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1053, - "end": 1090, - "replacementText": "m: number = an_array[Number.MAX_SAFE_INTEGER]", + "start": 1054, + "end": 1054, + "replacementText": ": number", "line": 32, "column": 7, "endLine": 32, @@ -716,9 +716,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1098, - "end": 1113, - "replacementText": "array: number[] = [1, 2, 3]", + "start": 1103, + "end": 1103, + "replacementText": ": number[]", "line": 35, "column": 5, "endLine": 35, @@ -945,9 +945,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1391, - "end": 1409, - "replacementText": "array1: number[] = [1, 2, 3]", + "start": 1397, + "end": 1397, + "replacementText": ": number[]", "line": 50, "column": 5, "endLine": 50, @@ -1060,9 +1060,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1436, - "end": 1454, - "replacementText": "array2: number[] = [1, 2, 3]", + "start": 1442, + "end": 1442, + "replacementText": ": number[]", "line": 53, "column": 5, "endLine": 53, @@ -1663,9 +1663,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1924, - "end": 1932, - "replacementText": "test: number = 1", + "start": 1928, + "end": 1928, + "replacementText": ": number", "line": 87, "column": 5, "endLine": 87, @@ -1798,9 +1798,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2154, - "end": 2169, - "replacementText": "array: number[] = [1, 2, 3]", + "start": 2159, + "end": 2159, + "replacementText": ": number[]", "line": 98, "column": 13, "endLine": 98, @@ -1948,4 +1948,4 @@ "severity": "ERROR" } ] -} +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets index 70fb78c3800c4408724f13f60875326f2d12a5d3..7266dd25101a50a8c50e62a93a01b2654ac08926 100644 --- a/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets +++ b/ets2panda/linter/test/main/array_index_expr_type.ets.migrate.ets @@ -19,7 +19,7 @@ import { } from '@kit.ArkUI'; function foo(index:number){ - let an_array: number[] = [1.0, 2.0, 3.0] + let an_array: number[] = [1.0,2.0,3.0] let a: number = an_array[index as int] let a1: number = an_array[(index + 1) as int] let a2: number = an_array[(index + 1.1) as int] @@ -37,7 +37,7 @@ function foo(index:number){ let m: number = an_array[Number.MAX_SAFE_INTEGER as int] } -let array: number[] = [1.0, 2.0, 3.0] +let array: number[] = [1.0,2.0,3.0] const index_1: number = 1.3; let index_2: number = 1.3; let index_3: number = 1.0; @@ -100,7 +100,7 @@ struct Test { async cateMode(testIndex: number) { emitter.on(innerEvent, (eventData) => { if (this.testIndex == 0.0) { - let array: number[] = [1.0, 2.0, 3.0]; + let array: number[] = [1.0,2.0,3.0]; array[this.testIndex as int]; } }) diff --git a/ets2panda/linter/test/main/comment_test.ets.autofix.json b/ets2panda/linter/test/main/comment_test.ets.autofix.json index e1951adff8ddddfaedb6f848ebbbffdc784079e6..9fc28462eacba428d5df2a5aba7ce9fa66971c48 100644 --- a/ets2panda/linter/test/main/comment_test.ets.autofix.json +++ b/ets2panda/linter/test/main/comment_test.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 669, - "end": 684, - "replacementText": "property: number = 123;", + "start": 677, + "end": 677, + "replacementText": ": number", "line": 20, "column": 5, "endLine": 20, @@ -64,9 +64,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 737, - "end": 750, - "replacementText": "arr: number[] = [1, 0];", + "start": 740, + "end": 740, + "replacementText": ": number[]", "line": 22, "column": 5, "endLine": 22, diff --git a/ets2panda/linter/test/main/custom_layout.ets.autofix.json b/ets2panda/linter/test/main/custom_layout.ets.autofix.json index 23fd6cb93cf96de9e3288cff0f2499cba8f50d71..491b4f1e67bae405604ae18203cfb27287346557 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.autofix.json +++ b/ets2panda/linter/test/main/custom_layout.ets.autofix.json @@ -295,9 +295,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1416, - "end": 1430, - "replacementText": "startPos: number = 300", + "start": 1424, + "end": 1424, + "replacementText": ": number", "line": 54, "column": 9, "endLine": 54, @@ -337,9 +337,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1476, - "end": 1519, - "replacementText": "pos: number = startPos - child.measureResult.height", + "start": 1479, + "end": 1479, + "replacementText": ": number", "line": 56, "column": 11, "endLine": 56, @@ -442,9 +442,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1958, - "end": 1968, - "replacementText": "size: number = 100", + "start": 1962, + "end": 1962, + "replacementText": ": number", "line": 80, "column": 9, "endLine": 80, @@ -631,9 +631,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2642, - "end": 2652, - "replacementText": "size: number = 100", + "start": 2646, + "end": 2646, + "replacementText": ": number", "line": 110, "column": 9, "endLine": 110, @@ -736,9 +736,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3055, - "end": 3069, - "replacementText": "startPos: number = 300", + "start": 3063, + "end": 3063, + "replacementText": ": number", "line": 121, "column": 9, "endLine": 121, @@ -778,9 +778,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3115, - "end": 3158, - "replacementText": "pos: number = startPos - child.measureResult.height", + "start": 3118, + "end": 3118, + "replacementText": ": number", "line": 123, "column": 11, "endLine": 123, diff --git a/ets2panda/linter/test/main/exponent.ets.autofix.json b/ets2panda/linter/test/main/exponent.ets.autofix.json index cc6218a973907d838d74561163aeb985f0df4a53..1ee1a7d8571b4f0c9e1569e949e06a586efdc593 100644 --- a/ets2panda/linter/test/main/exponent.ets.autofix.json +++ b/ets2panda/linter/test/main/exponent.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 609, - "end": 628, - "replacementText": "kk: number = Math.pow(6, 3)", + "start": 611, + "end": 611, + "replacementText": ": number", "line": 16, "column": 5, "endLine": 16, @@ -95,9 +95,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 652, - "end": 662, - "replacementText": "k: number = 5 ** 2", + "start": 653, + "end": 653, + "replacementText": ": number", "line": 19, "column": 5, "endLine": 19, diff --git a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json index 5d84566f2e6bf018a371494965a41f7db4df0c5a..4c95852a32b261a8705a0fc27cb1119ecc6bce3b 100644 --- a/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json +++ b/ets2panda/linter/test/main/literals_as_prop_names.ets.autofix.json @@ -761,9 +761,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2119, - "end": 2145, - "replacementText": "case17: number = Direction17[\"\\\\\"]", + "start": 2125, + "end": 2125, + "replacementText": ": number", "line": 105, "column": 5, "endLine": 105, @@ -792,9 +792,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2150, - "end": 2180, - "replacementText": "case172: number = Direction17[\"__x5c\"]", + "start": 2157, + "end": 2157, + "replacementText": ": number", "line": 106, "column": 5, "endLine": 106, diff --git a/ets2panda/linter/test/main/no_function_return_this.ets b/ets2panda/linter/test/main/no_function_return_this.ets new file mode 100644 index 0000000000000000000000000000000000000000..7642726e36ed3c8882ea0df6b8853513bde21077 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets @@ -0,0 +1,48 @@ +/* + * 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. + */ + +let t1 = Function('return this')(); // error + +let t2 = Function("return this")(); // error + +let t3 = Function(`return this`)(); // error + +let t4 = new Function('return this')(); // error + +let fn = Function('return this'); // error +let t5 = fn(); + +let t6 = (Function)('return this')(); // error + +let t7 = (globalThis.Function)('return this')(); // error + +let t8 = (0, Function)('return this')(); // error + +let t9 = (Function.bind(null))('return this')(); // error + +const body = "return this"; +let t10 = Function(body)(); // error + +let a1 = Function('return 123')(); // legal + +let a2 = Function('return window')(); // legal + +let a3 = Function('x', 'return this')(); // legal + +const a4 = Function; // legal + +let a5 = Function("return somethingElse")(); // legal + +let a7 = SomeOtherConstructor('return this'); // legal \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_function_return_this.ets.args.json b/ets2panda/linter/test/main/no_function_return_this.ets.args.json new file mode 100644 index 0000000000000000000000000000000000000000..4acc088d1da62353e56ced57f16b342de413cb78 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets.args.json @@ -0,0 +1,19 @@ +{ + "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": "" + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_function_return_this.ets.arkts2.json b/ets2panda/linter/test/main/no_function_return_this.ets.arkts2.json new file mode 100644 index 0000000000000000000000000000000000000000..3a1dcaed0a0807d9f70a8a76e2209221a3604e56 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets.arkts2.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": 16, + "column": 5, + "endLine": 16, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 33, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 16, + "column": 10, + "endLine": 16, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 10, + "endLine": 18, + "endColumn": 33, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 10, + "endLine": 18, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 10, + "endLine": 20, + "endColumn": 33, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 10, + "endLine": 20, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 39, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 10, + "endLine": 22, + "endColumn": 37, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 10, + "endLine": 22, + "endColumn": 37, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 10, + "endLine": 24, + "endColumn": 33, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 12, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 10, + "endLine": 27, + "endColumn": 35, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 10, + "endLine": 27, + "endColumn": 35, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 11, + "endLine": 27, + "endColumn": 19, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 10, + "endLine": 29, + "endColumn": 46, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 10, + "endLine": 29, + "endColumn": 46, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 30, + "problem": "GlobalThisError", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 22, + "endLine": 29, + "endColumn": 30, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 10, + "endLine": 31, + "endColumn": 38, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 10, + "endLine": 31, + "endColumn": 38, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 22, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 12, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 14, + "endLine": 31, + "endColumn": 22, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 5, + "endLine": 33, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 10, + "endLine": 33, + "endColumn": 46, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 20, + "endLine": 33, + "endColumn": 24, + "problem": "FunctionBindError", + "suggest": "", + "rule": "'Function.bind' is not supported (arkts-no-func-bind)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 27, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 11, + "endLine": 36, + "endColumn": 25, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 36, + "column": 11, + "endLine": 36, + "endColumn": 25, + "problem": "NoFunctionReturnThis", + "suggest": "", + "rule": "Function(\"return this\") is not supported (arkts-no-function-return-this)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 34, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 10, + "endLine": 38, + "endColumn": 32, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 5, + "endLine": 40, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 10, + "endLine": 40, + "endColumn": 35, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 5, + "endLine": 42, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 10, + "endLine": 42, + "endColumn": 38, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 12, + "endLine": 44, + "endColumn": 20, + "problem": "ClassAsObjectError", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 46, + "column": 10, + "endLine": 46, + "endColumn": 42, + "problem": "ExplicitFunctionType", + "suggest": "", + "rule": "The function type should be explicit (arkts-no-ts-like-function-call)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 5, + "endLine": 48, + "endColumn": 45, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_function_return_this.ets.json b/ets2panda/linter/test/main/no_function_return_this.ets.json new file mode 100644 index 0000000000000000000000000000000000000000..44fc2a3c888b0d859694801338cdb7358a6be175 --- /dev/null +++ b/ets2panda/linter/test/main/no_function_return_this.ets.json @@ -0,0 +1,238 @@ +{ + "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": 16, + "column": 5, + "endLine": 16, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 5, + "endLine": 18, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 5, + "endLine": 20, + "endColumn": 35, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 5, + "endLine": 22, + "endColumn": 39, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 5, + "endLine": 25, + "endColumn": 14, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 5, + "endLine": 27, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 11, + "endLine": 27, + "endColumn": 19, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 29, + "column": 5, + "endLine": 29, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 29, + "column": 11, + "endLine": 29, + "endColumn": 21, + "problem": "GlobalThis", + "suggest": "", + "rule": "\"globalThis\" is not supported (arkts-no-globalthis)", + "severity": "WARNING" + }, + { + "line": 29, + "column": 22, + "endLine": 29, + "endColumn": 30, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 31, + "column": 5, + "endLine": 31, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 11, + "endLine": 31, + "endColumn": 22, + "problem": "CommaOperator", + "suggest": "", + "rule": "The comma operator \",\" is supported only in \"for\" loops (arkts-no-comma-outside-loops)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 14, + "endLine": 31, + "endColumn": 22, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 33, + "column": 5, + "endLine": 33, + "endColumn": 48, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 20, + "endLine": 33, + "endColumn": 30, + "problem": "FunctionBind", + "suggest": "", + "rule": "'Function.bind' is not supported (arkts-no-func-bind)", + "severity": "WARNING" + }, + { + "line": 36, + "column": 5, + "endLine": 36, + "endColumn": 27, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 38, + "column": 5, + "endLine": 38, + "endColumn": 34, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 40, + "column": 5, + "endLine": 40, + "endColumn": 37, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 42, + "column": 5, + "endLine": 42, + "endColumn": 40, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 44, + "column": 12, + "endLine": 44, + "endColumn": 20, + "problem": "ClassAsObject", + "suggest": "", + "rule": "Classes cannot be used as objects (arkts-no-classes-as-obj)", + "severity": "WARNING" + }, + { + "line": 46, + "column": 5, + "endLine": 46, + "endColumn": 44, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + }, + { + "line": 48, + "column": 5, + "endLine": 48, + "endColumn": 45, + "problem": "AnyType", + "suggest": "", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets b/ets2panda/linter/test/main/no_import_concurrency.ets index 9eb3c99118766d1011341a40fe3f2976f2df5c9d..7602f347cf2980eb0993c3d4eae0a8435f9a3a77 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets +++ b/ets2panda/linter/test/main/no_import_concurrency.ets @@ -25,7 +25,6 @@ import fooke from '@ohos.process'; import { process as ps, collections as clt } from '@kit.ArkTS'; import process from '@ohos.process'; import aaa from '@ohos.taskpool' -import aa from '@arkts.utils' import aaaa from '@arkts.collections'; aaa.getTaskPoolInfo() @@ -37,7 +36,6 @@ function concurrency () { ps.isIsolatedProcess(); tsk.cancel(); -aa.locks.AsyncLock aaaa.Set() clt.Set() fooAs.getFoo(); diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json index d3aaa8c933a1854550d6ae1f5078a23c6f554af5..f23fdd92f6b74c9170ea2a05d90a0ac754077976 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.arkts2.json @@ -1,178 +1,168 @@ { - "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": 17, - "column": 21, - "endLine": 17, - "endColumn": 36, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 8, - "endLine": 19, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 25, - "endLine": 20, - "endColumn": 42, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 15, - "endLine": 21, - "endColumn": 32, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 21, - "column": 34, - "endLine": 21, - "endColumn": 47, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 16, - "endLine": 23, - "endColumn": 31, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 23, - "column": 33, - "endLine": 23, - "endColumn": 47, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 8, - "endLine": 24, - "endColumn": 13, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 10, - "endLine": 25, - "endColumn": 23, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 25, - "endLine": 25, - "endColumn": 43, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 8, - "endLine": 26, - "endColumn": 15, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 8, - "endLine": 27, - "endColumn": 11, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 10, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 8, - "endLine": 29, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 34, - "column": 11, - "endLine": 34, - "endColumn": 20, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - }, - { - "line": 34, - "column": 17, - "endLine": 34, - "endColumn": 20, - "problem": "NumericSemantics", - "suggest": "", - "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", - "severity": "ERROR" - } - ] -} \ No newline at end of file + "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": 17, + "column": 21, + "endLine": 17, + "endColumn": 36, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 19, + "column": 8, + "endLine": 19, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 25, + "endLine": 20, + "endColumn": 42, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 15, + "endLine": 21, + "endColumn": 32, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 21, + "column": 34, + "endLine": 21, + "endColumn": 47, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 16, + "endLine": 23, + "endColumn": 31, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 23, + "column": 33, + "endLine": 23, + "endColumn": 47, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 8, + "endLine": 24, + "endColumn": 13, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 10, + "endLine": 25, + "endColumn": 23, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 25, + "endLine": 25, + "endColumn": 43, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 8, + "endLine": 26, + "endColumn": 15, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 8, + "endLine": 27, + "endColumn": 11, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 8, + "endLine": 28, + "endColumn": 12, + "problem": "LimitedStdLibNoImportConcurrency", + "suggest": "", + "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 11, + "endLine": 33, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 33, + "column": 17, + "endLine": 33, + "endColumn": 20, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + } + ] +} diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json b/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json index 6c5606e0185c023b67988ae8be32675471370e3b..ad3c6460fae5fbdd747cf9ee3331686dd3a363cc 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.autofix.json @@ -136,8 +136,8 @@ "endColumn": 31 }, { - "start": 1397, - "end": 1400, + "start": 1367, + "end": 1370, "replacementText": "taskpool", "line": 23, "column": 16, @@ -208,8 +208,8 @@ "endColumn": 23 }, { - "start": 1373, - "end": 1375, + "start": 1343, + "end": 1345, "replacementText": "process", "line": 25, "column": 10, @@ -238,8 +238,8 @@ "endColumn": 43 }, { - "start": 1441, - "end": 1444, + "start": 1392, + "end": 1395, "replacementText": "collections", "line": 25, "column": 25, @@ -289,8 +289,8 @@ "endColumn": 11 }, { - "start": 1278, - "end": 1281, + "start": 1248, + "end": 1251, "replacementText": "taskpool", "line": 27, "column": 8, @@ -306,55 +306,25 @@ "line": 28, "column": 8, "endLine": 28, - "endColumn": 10, + "endColumn": 12, "problem": "LimitedStdLibNoImportConcurrency", "autofix": [ { "start": 1208, - "end": 1237, + "end": 1246, "replacementText": "", "line": 28, "column": 8, "endLine": 28, - "endColumn": 10 - }, - { - "start": 1411, - "end": 1413, - "replacementText": "ArkTSUtils", - "line": 28, - "column": 8, - "endLine": 28, - "endColumn": 10 - } - ], - "suggest": "", - "rule": "Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)", - "severity": "ERROR" - }, - { - "line": 29, - "column": 8, - "endLine": 29, - "endColumn": 12, - "problem": "LimitedStdLibNoImportConcurrency", - "autofix": [ - { - "start": 1238, - "end": 1276, - "replacementText": "", - "line": 29, - "column": 8, - "endLine": 29, "endColumn": 12 }, { - "start": 1430, - "end": 1434, + "start": 1381, + "end": 1385, "replacementText": "collections", - "line": 29, + "line": 28, "column": 8, - "endLine": 29, + "endLine": 28, "endColumn": 12 } ], @@ -363,19 +333,19 @@ "severity": "ERROR" }, { - "line": 34, + "line": 33, "column": 11, - "endLine": 34, + "endLine": 33, "endColumn": 20, "problem": "NumericSemantics", "autofix": [ { - "start": 1337, - "end": 1346, - "replacementText": "aaa: number = 123", - "line": 34, + "start": 1310, + "end": 1310, + "replacementText": ": number", + "line": 33, "column": 11, - "endLine": 34, + "endLine": 33, "endColumn": 20 } ], @@ -384,19 +354,19 @@ "severity": "ERROR" }, { - "line": 34, + "line": 33, "column": 17, - "endLine": 34, + "endLine": 33, "endColumn": 20, "problem": "NumericSemantics", "autofix": [ { - "start": 1343, - "end": 1346, + "start": 1313, + "end": 1316, "replacementText": "123.0", - "line": 34, + "line": 33, "column": 17, - "endLine": 34, + "endLine": 33, "endColumn": 20 } ], diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets index 4fcec2676d87b284296b19f507e5d75feed4910f..f159439aa475095e71d5c957d527210d4f87a1a8 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.ets @@ -27,7 +27,6 @@ import bbbb from '@kit.ArkTS'; - taskpool.getTaskPoolInfo() function concurrency () { @@ -37,7 +36,6 @@ function concurrency () { process.isIsolatedProcess(); taskpool.cancel(); -ArkTSUtils.locks.AsyncLock Set() Set() fooAs.getFoo(); diff --git a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json index c7db0a9d1487d65a3b6d10b4de007317aece3726..75faa009317be813e325733eb9cce302f88bbc8c 100644 --- a/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json +++ b/ets2panda/linter/test/main/no_import_concurrency.ets.migrate.json @@ -15,9 +15,9 @@ ], "result": [ { - "line": 41, + "line": 39, "column": 1, - "endLine": 41, + "endLine": 39, "endColumn": 6, "problem": "GenericCallNoTypeArgs", "suggest": "", @@ -25,9 +25,9 @@ "severity": "ERROR" }, { - "line": 42, + "line": 40, "column": 1, - "endLine": 42, + "endLine": 40, "endColumn": 6, "problem": "GenericCallNoTypeArgs", "suggest": "", diff --git a/ets2panda/linter/test/main/numeric_semantics.ets b/ets2panda/linter/test/main/numeric_semantics.ets index c04cf3209c05fe00a5065dbb5cdd6a7fee6e1f82..39c3b1a564040c3ee5637e66bfacd6f9c8be9ca9 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets @@ -104,9 +104,9 @@ identity(42); let an_array = [1,2,3] -let g = an_array[] +let g2 = an_array[] -const a = 1 +const a2 = 1 enum Test { A = 1, // 显式赋值为 1 @@ -142,7 +142,8 @@ export class G{ const fingerprintPositionY = AppStorage.get(FingerprintConstants.COORDINATE_Y_OF_FINGERPRINT_UD_SCREEN_IN_PX) ?? 0; -private doCloseFolderBackgroundAnimation(): void { +class Layout { + private doCloseFolderBackgroundAnimation(): void { openFolderLayout.getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight; openFolderLayout.getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth; @@ -161,9 +162,10 @@ private doCloseFolderBackgroundAnimation(): void { openFolderLayout.getGridSwiperLayout().bgTranslateY = pos[1] + editModeTranslateY - openFolderLayout.getBackgroundLayout().closedHeight * 0.5 - openFolderLayout.getBackgroundLayout().openedMargin; } + } } -let f = 0.0; +let f2 = 0.0; let b5: number = 0; f = b5; // OK @@ -182,9 +184,9 @@ e = e | 3; // OK let arr1 = [1,2,3] e += arr1[0]; // OK -let a = 0.0; -a = fun1(); -a = fun2()!; +let a3 = 0.0; +a3 = fun1(); +a3 = fun2()!; function fun1():number{ return 1; @@ -196,17 +198,17 @@ function fun2():number|undefined{ import { ArrayList } from "@kit.ArkTS"; -let arr = new ArrayList() +let arr2 = new ArrayList() for (let i:number = 0; i < 100; i++) { - arr.add(i) + arr2.add(i) } -let cancelIds:ArrayList = arr.subArrayList(6, 86) -let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) +let cancelIds:ArrayList = arr2.subArrayList(6, 86) +let arr3: Array = Array.from(cancelIds) +let arr4: Array = Array.from(new ArrayList()) -let a:number = 0.000; +let a4: number = 0.000; -const b:number = 0.000; +const b4: number = 0.000; export enum WalletStageValue { DEFAULT = 0, @@ -229,3 +231,10 @@ export enum AnimationStage { class C { public static readonly SIX_MONTH = 180 * 24 * 60 * 60 * 1000 } + +function testIndentation(): void { + let a = (() => { + console.log('hello'); + return 0; + })(); +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json index d7bc71bee6c0d885b12ab73d0771f0f30c34dced..0cb967d9fef64e76cb78c887e31e707987585d35 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.arkts2.json @@ -468,7 +468,7 @@ "line": 107, "column": 5, "endLine": 107, - "endColumn": 19, + "endColumn": 20, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -476,9 +476,9 @@ }, { "line": 107, - "column": 18, + "column": 19, "endLine": 107, - "endColumn": 18, + "endColumn": 19, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -488,7 +488,7 @@ "line": 109, "column": 7, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -496,9 +496,9 @@ }, { "line": 109, - "column": 11, + "column": 12, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", @@ -705,109 +705,19 @@ "severity": "ERROR" }, { - "line": 145, - "column": 45, - "endLine": 145, - "endColumn": 49, - "problem": "VoidOperator", - "suggest": "", - "rule": "\"void\" operator is not supported (arkts-no-void-operator)", - "severity": "ERROR" - }, - { - "line": 145, - "column": 50, - "endLine": 145, - "endColumn": 51, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 146, - "column": 5, - "endLine": 146, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 147, - "column": 5, - "endLine": 147, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, - "column": 5, - "endLine": 149, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, + "line": 150, "column": 9, - "endLine": 149, + "endLine": 150, "endColumn": 23, - "problem": "ObjectLiteralProperty", + "problem": "NumericSemantics", "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { "line": 150, - "column": 5, - "endLine": 150, - "endColumn": 104, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 5, - "endLine": 151, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 9, - "endLine": 151, - "endColumn": 61, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 12, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, "column": 17, - "endLine": 149, + "endLine": 150, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -815,49 +725,29 @@ "severity": "ERROR" }, { - "line": 149, + "line": 150, "column": 21, - "endLine": 149, + "endLine": 150, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "InvalidIdentifier", - "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", - "severity": "ERROR" - }, { "line": 152, "column": 9, "endLine": 152, - "endColumn": 12, + "endColumn": 61, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 152, + "line": 153, "column": 22, - "endLine": 152, + "endLine": 153, "endColumn": 23, "problem": "NumericSemantics", "suggest": "", @@ -865,9 +755,9 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 100, - "endLine": 153, + "endLine": 154, "endColumn": 101, "problem": "NumericSemantics", "suggest": "", @@ -875,9 +765,19 @@ "severity": "ERROR" }, { - "line": 160, + "line": 161, + "column": 61, + "endLine": 161, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 161, "column": 84, - "endLine": 160, + "endLine": 161, "endColumn": 85, "problem": "NumericSemantics", "suggest": "", @@ -885,19 +785,29 @@ "severity": "ERROR" }, { - "line": 166, + "line": 162, + "column": 61, + "endLine": 162, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 168, "column": 5, - "endLine": 166, - "endColumn": 12, + "endLine": 168, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 167, + "line": 169, "column": 18, - "endLine": 167, + "endLine": 169, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -905,9 +815,9 @@ "severity": "ERROR" }, { - "line": 170, + "line": 172, "column": 5, - "endLine": 170, + "endLine": 172, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -915,9 +825,9 @@ "severity": "ERROR" }, { - "line": 171, + "line": 173, "column": 18, - "endLine": 171, + "endLine": 173, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -925,9 +835,9 @@ "severity": "ERROR" }, { - "line": 180, + "line": 182, "column": 9, - "endLine": 180, + "endLine": 182, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -935,9 +845,9 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 9, - "endLine": 181, + "endLine": 183, "endColumn": 10, "problem": "NumericSemantics", "suggest": "", @@ -945,9 +855,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 5, - "endLine": 182, + "endLine": 184, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -955,9 +865,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 13, - "endLine": 182, + "endLine": 184, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -965,9 +875,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 15, - "endLine": 182, + "endLine": 184, "endColumn": 16, "problem": "NumericSemantics", "suggest": "", @@ -975,9 +885,9 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 17, - "endLine": 182, + "endLine": 184, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -985,9 +895,9 @@ "severity": "ERROR" }, { - "line": 183, + "line": 185, "column": 6, - "endLine": 183, + "endLine": 185, "endColumn": 13, "problem": "RuntimeArrayCheck", "suggest": "", @@ -995,19 +905,19 @@ "severity": "ERROR" }, { - "line": 185, + "line": 187, "column": 5, - "endLine": 185, - "endColumn": 12, + "endLine": 187, + "endColumn": 13, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 190, + "line": 192, "column": 10, - "endLine": 190, + "endLine": 192, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1015,9 +925,9 @@ "severity": "ERROR" }, { - "line": 194, + "line": 196, "column": 10, - "endLine": 194, + "endLine": 196, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1025,9 +935,9 @@ "severity": "ERROR" }, { - "line": 197, + "line": 199, "column": 1, - "endLine": 197, + "endLine": 199, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -1035,29 +945,29 @@ "severity": "ERROR" }, { - "line": 199, + "line": 201, "column": 5, - "endLine": 199, - "endColumn": 34, + "endLine": 201, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 199, - "column": 15, - "endLine": 199, - "endColumn": 24, + "line": 201, + "column": 16, + "endLine": 201, + "endColumn": 25, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 21, - "endLine": 200, + "endLine": 202, "endColumn": 22, "problem": "NumericSemantics", "suggest": "", @@ -1065,9 +975,9 @@ "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 28, - "endLine": 200, + "endLine": 202, "endColumn": 31, "problem": "NumericSemantics", "suggest": "", @@ -1075,29 +985,29 @@ "severity": "ERROR" }, { - "line": 203, - "column": 52, - "endLine": 203, - "endColumn": 53, + "line": 205, + "column": 53, + "endLine": 205, + "endColumn": 54, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 203, - "column": 55, - "endLine": 203, - "endColumn": 57, + "line": 205, + "column": 56, + "endLine": 205, + "endColumn": 58, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { - "line": 205, + "line": 207, "column": 42, - "endLine": 205, + "endLine": 207, "endColumn": 51, "problem": "DynamicCtorCall", "suggest": "", @@ -1105,9 +1015,9 @@ "severity": "ERROR" }, { - "line": 212, + "line": 214, "column": 13, - "endLine": 212, + "endLine": 214, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -1115,9 +1025,9 @@ "severity": "ERROR" }, { - "line": 213, + "line": 215, "column": 17, - "endLine": 213, + "endLine": 215, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -1125,9 +1035,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 17, - "endLine": 214, + "endLine": 216, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -1135,9 +1045,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 17, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -1145,9 +1055,9 @@ "severity": "ERROR" }, { - "line": 216, + "line": 218, "column": 19, - "endLine": 216, + "endLine": 218, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -1155,9 +1065,9 @@ "severity": "ERROR" }, { - "line": 217, + "line": 219, "column": 18, - "endLine": 217, + "endLine": 219, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -1165,9 +1075,9 @@ "severity": "ERROR" }, { - "line": 218, + "line": 220, "column": 20, - "endLine": 218, + "endLine": 220, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -1175,9 +1085,9 @@ "severity": "ERROR" }, { - "line": 222, + "line": 224, "column": 10, - "endLine": 222, + "endLine": 224, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -1185,9 +1095,9 @@ "severity": "ERROR" }, { - "line": 223, + "line": 225, "column": 11, - "endLine": 223, + "endLine": 225, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -1195,9 +1105,9 @@ "severity": "ERROR" }, { - "line": 224, + "line": 226, "column": 14, - "endLine": 224, + "endLine": 226, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -1205,9 +1115,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 227, "column": 16, - "endLine": 225, + "endLine": 227, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -1215,9 +1125,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 14, - "endLine": 226, + "endLine": 228, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -1225,9 +1135,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 3, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "suggest": "", @@ -1235,9 +1145,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 38, - "endLine": 230, + "endLine": 232, "endColumn": 41, "problem": "NumericSemantics", "suggest": "", @@ -1245,9 +1155,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 44, - "endLine": 230, + "endLine": 232, "endColumn": 46, "problem": "NumericSemantics", "suggest": "", @@ -1255,9 +1165,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 49, - "endLine": 230, + "endLine": 232, "endColumn": 51, "problem": "NumericSemantics", "suggest": "", @@ -1265,9 +1175,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 54, - "endLine": 230, + "endLine": 232, "endColumn": 56, "problem": "NumericSemantics", "suggest": "", @@ -1275,15 +1185,35 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 59, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "suggest": "", "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 236, + "column": 7, + "endLine": 239, + "endColumn": 7, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 12, + "endLine": 238, + "endColumn": 13, + "problem": "NumericSemantics", + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -1345,9 +1275,9 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 46, - "endLine": 153, + "endLine": 154, "endColumn": 56, "problem": "UIInterfaceImport", "suggest": "", @@ -1355,9 +1285,9 @@ "severity": "ERROR" }, { - "line": 154, + "line": 155, "column": 33, - "endLine": 154, + "endLine": 155, "endColumn": 43, "problem": "UIInterfaceImport", "suggest": "", @@ -1365,9 +1295,9 @@ "severity": "ERROR" }, { - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44, "problem": "UIInterfaceImport", "suggest": "", diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json index 72ddcbaa863effb8817cf4602190402e159164a8..6ece33eb7ae5eef6d36f8ee43560d4709b45c56f 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 744, - "end": 749, - "replacementText": "a: number = 1", + "start": 745, + "end": 745, + "replacementText": ": number", "line": 18, "column": 5, "endLine": 18, @@ -190,9 +190,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1377, - "end": 1384, - "replacementText": "c: number = 1.5", + "start": 1378, + "end": 1378, + "replacementText": ": number", "line": 39, "column": 5, "endLine": 39, @@ -211,9 +211,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1561, - "end": 1566, - "replacementText": "d: number = 2", + "start": 1562, + "end": 1562, + "replacementText": ": number", "line": 45, "column": 5, "endLine": 45, @@ -253,9 +253,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1712, - "end": 1717, - "replacementText": "n: number = 2", + "start": 1713, + "end": 1713, + "replacementText": ": number", "line": 51, "column": 5, "endLine": 51, @@ -316,9 +316,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1747, - "end": 1760, - "replacementText": "g: number[] = [1, 2, 3]", + "start": 1748, + "end": 1748, + "replacementText": ": number[]", "line": 55, "column": 5, "endLine": 55, @@ -410,9 +410,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1786, - "end": 1799, - "replacementText": "t8: number = Infinity", + "start": 1788, + "end": 1788, + "replacementText": ": number", "line": 59, "column": 5, "endLine": 59, @@ -431,9 +431,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1807, - "end": 1821, - "replacementText": "t9: number = -Infinity", + "start": 1809, + "end": 1809, + "replacementText": ": number", "line": 61, "column": 5, "endLine": 61, @@ -452,9 +452,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1830, - "end": 1839, - "replacementText": "t10: number = NaN", + "start": 1833, + "end": 1833, + "replacementText": ": number", "line": 63, "column": 5, "endLine": 63, @@ -473,9 +473,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1848, - "end": 1870, - "replacementText": "t11: number = Number.MAX_VALUE", + "start": 1851, + "end": 1851, + "replacementText": ": number", "line": 65, "column": 5, "endLine": 65, @@ -494,9 +494,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1879, - "end": 1901, - "replacementText": "t12: number = Number.MIN_VALUE", + "start": 1882, + "end": 1882, + "replacementText": ": number", "line": 67, "column": 5, "endLine": 67, @@ -557,9 +557,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1959, - "end": 1965, - "replacementText": "o2: number = o", + "start": 1961, + "end": 1961, + "replacementText": ": number", "line": 73, "column": 5, "endLine": 73, @@ -578,9 +578,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1975, - "end": 1982, - "replacementText": "o3: number = oo", + "start": 1977, + "end": 1977, + "replacementText": ": number", "line": 75, "column": 5, "endLine": 75, @@ -599,9 +599,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2001, - "end": 2007, - "replacementText": "a: number = 1;", + "start": 2002, + "end": 2002, + "replacementText": ": number", "line": 78, "column": 4, "endLine": 78, @@ -641,9 +641,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2043, - "end": 2052, - "replacementText": "t2: number = +123", + "start": 2045, + "end": 2045, + "replacementText": ": number", "line": 83, "column": 5, "endLine": 83, @@ -683,9 +683,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2061, - "end": 2070, - "replacementText": "t3: number = -234", + "start": 2063, + "end": 2063, + "replacementText": ": number", "line": 85, "column": 5, "endLine": 85, @@ -725,9 +725,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2079, - "end": 2100, - "replacementText": "num: number = Math.floor(4.8)", + "start": 2082, + "end": 2082, + "replacementText": ": number", "line": 87, "column": 5, "endLine": 87, @@ -746,9 +746,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2124, - "end": 2146, - "replacementText": "value: number = parseInt(\"42\")", + "start": 2129, + "end": 2129, + "replacementText": ": number", "line": 89, "column": 5, "endLine": 89, @@ -767,9 +767,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2188, - "end": 2193, - "replacementText": "x: number = 2", + "start": 2189, + "end": 2189, + "replacementText": ": number", "line": 92, "column": 1, "endLine": 94, @@ -788,9 +788,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2195, - "end": 2200, - "replacementText": "y: number = 3", + "start": 2196, + "end": 2196, + "replacementText": ": number", "line": 92, "column": 1, "endLine": 94, @@ -914,9 +914,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2368, - "end": 2386, - "replacementText": "an_array: number[] = [1, 2, 3]", + "start": 2376, + "end": 2376, + "replacementText": ": number[]", "line": 105, "column": 5, "endLine": 105, @@ -994,17 +994,17 @@ "line": 107, "column": 5, "endLine": 107, - "endColumn": 19, + "endColumn": 20, "problem": "NumericSemantics", "autofix": [ { - "start": 2394, - "end": 2408, - "replacementText": "g: number = an_array[]", + "start": 2396, + "end": 2396, + "replacementText": ": number", "line": 107, "column": 5, "endLine": 107, - "endColumn": 19 + "endColumn": 20 } ], "suggest": "", @@ -1013,9 +1013,9 @@ }, { "line": 107, - "column": 18, + "column": 19, "endLine": 107, - "endColumn": 18, + "endColumn": 19, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -1025,17 +1025,17 @@ "line": 109, "column": 7, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 2418, - "end": 2423, - "replacementText": "a: number = 1", + "start": 2421, + "end": 2421, + "replacementText": ": number", "line": 109, "column": 7, "endLine": 109, - "endColumn": 12 + "endColumn": 13 } ], "suggest": "", @@ -1044,19 +1044,19 @@ }, { "line": 109, - "column": 11, + "column": 12, "endLine": 109, - "endColumn": 12, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 2422, - "end": 2423, + "start": 2424, + "end": 2425, "replacementText": "1.0", "line": 109, - "column": 11, + "column": 12, "endLine": 109, - "endColumn": 12 + "endColumn": 13 } ], "suggest": "", @@ -1091,9 +1091,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2493, - "end": 2506, - "replacementText": "test: number = Test.A", + "start": 2499, + "end": 2499, + "replacementText": ": number", "line": 115, "column": 7, "endLine": 115, @@ -1112,9 +1112,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2593, - "end": 2609, - "replacementText": "readonly c1: number = 1;", + "start": 2606, + "end": 2606, + "replacementText": ": number", "line": 121, "column": 3, "endLine": 121, @@ -1133,8 +1133,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2607, - "end": 2608, + "start": 2609, + "end": 2610, "replacementText": "1.0", "line": 121, "column": 17, @@ -1154,9 +1154,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2620, - "end": 2638, - "replacementText": "readonly c4: number = 1.7;", + "start": 2633, + "end": 2633, + "replacementText": ": number", "line": 122, "column": 3, "endLine": 122, @@ -1175,9 +1175,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2651, - "end": 2671, - "replacementText": "readonly c5: number = 0x123;", + "start": 2664, + "end": 2664, + "replacementText": ": number", "line": 123, "column": 3, "endLine": 123, @@ -1196,9 +1196,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2683, - "end": 2703, - "replacementText": "readonly c6: number = 0o123;", + "start": 2696, + "end": 2696, + "replacementText": ": number", "line": 124, "column": 3, "endLine": 124, @@ -1217,9 +1217,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2713, - "end": 2733, - "replacementText": "readonly c7: number = 0b101;", + "start": 2726, + "end": 2726, + "replacementText": ": number", "line": 125, "column": 3, "endLine": 125, @@ -1238,9 +1238,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2743, - "end": 2764, - "replacementText": "readonly c8: number[] = [1, 2, 3];", + "start": 2756, + "end": 2756, + "replacementText": ": number[]", "line": 126, "column": 3, "endLine": 126, @@ -1259,8 +1259,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2758, - "end": 2759, + "start": 2760, + "end": 2761, "replacementText": "1.0", "line": 126, "column": 18, @@ -1280,8 +1280,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2760, - "end": 2761, + "start": 2762, + "end": 2763, "replacementText": "2.0", "line": 126, "column": 20, @@ -1301,8 +1301,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2762, - "end": 2763, + "start": 2764, + "end": 2765, "replacementText": "3.0", "line": 126, "column": 22, @@ -1322,9 +1322,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2893, - "end": 2899, - "replacementText": "c1: number = 1", + "start": 2897, + "end": 2897, + "replacementText": ": number", "line": 137, "column": 7, "endLine": 137, @@ -1343,8 +1343,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2898, - "end": 2899, + "start": 2900, + "end": 2901, "replacementText": "1.0", "line": 137, "column": 12, @@ -1364,9 +1364,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2923, - "end": 2939, - "replacementText": "readonly a5: number = 4;", + "start": 2936, + "end": 2936, + "replacementText": ": number", "line": 140, "column": 3, "endLine": 140, @@ -1385,8 +1385,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2937, - "end": 2938, + "start": 2939, + "end": 2940, "replacementText": "4.0", "line": 140, "column": 17, @@ -1416,9 +1416,9 @@ "problem": "NumericSemantics", "autofix": [ { - "replacementText": "fingerprintPositionY: number = AppStorage.get(FingerprintConstants.COORDINATE_Y_OF_FINGERPRINT_UD_SCREEN_IN_PX) ?? 0", - "start": 2952, - "end": 3068, + "start": 2974, + "end": 2974, + "replacementText": ": number", "line": 143, "column": 30, "endLine": 143, @@ -1437,8 +1437,8 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3067, - "end": 3068, + "start": 3069, + "end": 3070, "replacementText": "0.0", "line": 143, "column": 122, @@ -1451,207 +1451,40 @@ "severity": "ERROR" }, { - "line": 145, - "column": 45, - "endLine": 145, - "endColumn": 49, - "problem": "VoidOperator", - "autofix": [ - { - "start": 3117, - "end": 3558, - "replacementText": "(() => {\r\n ({\r\n openFolderLayout, : .getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight,\r\n openFolderLayout, : .getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth,\r\n let, pos = [-1, -1],\r\n pos = folderLayoutUtil.getFolderComponentCenterPosition(FolderData.getInstance().getOpenedFolder()),\r\n let, editModeTranslateY = this.getEditModeTranslateY(pos),\r\n if(pos) { }, : .length > 1\r\n });\r\n return undefined;\r\n})()", - "line": 145, - "column": 45, - "endLine": 145, - "endColumn": 49 - } - ], - "suggest": "", - "rule": "\"void\" operator is not supported (arkts-no-void-operator)", - "severity": "ERROR" - }, - { - "line": 145, - "column": 50, - "endLine": 145, - "endColumn": 51, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 146, - "column": 5, - "endLine": 146, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3129, - "end": 3145, - "replacementText": "openFolderLayout: openFolderLayout", - "line": 146, - "column": 5, - "endLine": 146, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 147, - "column": 5, - "endLine": 147, - "endColumn": 21, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3237, - "end": 3253, - "replacementText": "openFolderLayout: openFolderLayout", - "line": 147, - "column": 5, - "endLine": 147, - "endColumn": 21 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, - "column": 5, - "endLine": 149, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3345, - "end": 3348, - "replacementText": "let: let", - "line": 149, - "column": 5, - "endLine": 149, - "endColumn": 8 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, + "line": 150, "column": 9, - "endLine": 149, + "endLine": 150, "endColumn": 23, - "problem": "ObjectLiteralProperty", + "problem": "NumericSemantics", "autofix": [ { - "start": 3349, - "end": 3363, - "replacementText": "pos: pos", - "line": 149, + "start": 3372, + "end": 3372, + "replacementText": ": number[]", + "line": 150, "column": 9, - "endLine": 149, + "endLine": 150, "endColumn": 23 } ], "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, { "line": 150, - "column": 5, - "endLine": 150, - "endColumn": 104, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3370, - "end": 3469, - "replacementText": "pos: pos", - "line": 150, - "column": 5, - "endLine": 150, - "endColumn": 104 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 5, - "endLine": 151, - "endColumn": 8, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3476, - "end": 3479, - "replacementText": "let: let", - "line": 151, - "column": 5, - "endLine": 151, - "endColumn": 8 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 151, - "column": 9, - "endLine": 151, - "endColumn": 61, - "problem": "ObjectLiteralProperty", - "autofix": [ - { - "start": 3480, - "end": 3532, - "replacementText": "editModeTranslateY: editModeTranslateY", - "line": 151, - "column": 9, - "endLine": 151, - "endColumn": 61 - } - ], - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 12, - "problem": "ObjectLiteralProperty", - "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", - "severity": "ERROR" - }, - { - "line": 149, "column": 17, - "endLine": 149, + "endLine": 150, "endColumn": 18, "problem": "NumericSemantics", "autofix": [ { - "start": 3356, - "end": 3358, + "start": 3376, + "end": 3378, "replacementText": "-1.0", - "line": 149, + "line": 150, "column": 17, - "endLine": 149, + "endLine": 150, "endColumn": 18 } ], @@ -1660,19 +1493,19 @@ "severity": "ERROR" }, { - "line": 149, + "line": 150, "column": 21, - "endLine": 149, + "endLine": 150, "endColumn": 22, "problem": "NumericSemantics", "autofix": [ { - "start": 3360, - "end": 3362, + "start": 3380, + "end": 3382, "replacementText": "-1.0", - "line": 149, + "line": 150, "column": 21, - "endLine": 149, + "endLine": 150, "endColumn": 22 } ], @@ -1680,50 +1513,30 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "InvalidIdentifier", - "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", - "severity": "ERROR" - }, { "line": 152, "column": 9, "endLine": 152, - "endColumn": 12, + "endColumn": 61, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 152, + "line": 153, "column": 22, - "endLine": 152, + "endLine": 153, "endColumn": 23, "problem": "NumericSemantics", "autofix": [ { - "start": 3556, - "end": 3557, + "start": 3576, + "end": 3577, "replacementText": "1.0", - "line": 152, + "line": 153, "column": 22, - "endLine": 152, + "endLine": 153, "endColumn": 23 } ], @@ -1732,19 +1545,19 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 100, - "endLine": 153, + "endLine": 154, "endColumn": 101, "problem": "NumericSemantics", "autofix": [ { - "start": 3661, - "end": 3662, + "start": 3681, + "end": 3682, "replacementText": "0.0", - "line": 153, + "line": 154, "column": 100, - "endLine": 153, + "endLine": 154, "endColumn": 101 } ], @@ -1753,19 +1566,29 @@ "severity": "ERROR" }, { - "line": 160, + "line": 161, + "column": 61, + "endLine": 161, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 161, "column": 84, - "endLine": 160, + "endLine": 161, "endColumn": 85, "problem": "NumericSemantics", "autofix": [ { - "start": 4128, - "end": 4129, + "start": 4148, + "end": 4149, "replacementText": "2.0", - "line": 160, + "line": 161, "column": 84, - "endLine": 160, + "endLine": 161, "endColumn": 85 } ], @@ -1774,20 +1597,30 @@ "severity": "ERROR" }, { - "line": 166, + "line": 162, + "column": 61, + "endLine": 162, + "endColumn": 67, + "problem": "RuntimeArrayCheck", + "suggest": "", + "rule": "Array bound not checked. (arkts-runtime-array-check)", + "severity": "ERROR" + }, + { + "line": 168, "column": 5, - "endLine": 166, - "endColumn": 12, + "endLine": 168, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 4388, - "end": 4395, - "replacementText": "f: number = 0.0", - "line": 166, + "start": 4415, + "end": 4415, + "replacementText": ": number", + "line": 168, "column": 5, - "endLine": 166, - "endColumn": 12 + "endLine": 168, + "endColumn": 13 } ], "suggest": "", @@ -1795,19 +1628,19 @@ "severity": "ERROR" }, { - "line": 167, + "line": 169, "column": 18, - "endLine": 167, + "endLine": 169, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 4415, - "end": 4416, + "start": 4441, + "end": 4442, "replacementText": "0.0", - "line": 167, + "line": 169, "column": 18, - "endLine": 167, + "endLine": 169, "endColumn": 19 } ], @@ -1816,19 +1649,19 @@ "severity": "ERROR" }, { - "line": 170, + "line": 172, "column": 5, - "endLine": 170, + "endLine": 172, "endColumn": 12, "problem": "NumericSemantics", "autofix": [ { - "start": 4440, - "end": 4447, - "replacementText": "e: number = 0.0", - "line": 170, + "start": 4467, + "end": 4467, + "replacementText": ": number", + "line": 172, "column": 5, - "endLine": 170, + "endLine": 172, "endColumn": 12 } ], @@ -1837,19 +1670,19 @@ "severity": "ERROR" }, { - "line": 171, + "line": 173, "column": 18, - "endLine": 171, + "endLine": 173, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 4467, - "end": 4468, + "start": 4493, + "end": 4494, "replacementText": "0.0", - "line": 171, + "line": 173, "column": 18, - "endLine": 171, + "endLine": 173, "endColumn": 19 } ], @@ -1858,19 +1691,19 @@ "severity": "ERROR" }, { - "line": 180, + "line": 182, "column": 9, - "endLine": 180, + "endLine": 182, "endColumn": 10, "problem": "NumericSemantics", "autofix": [ { - "start": 4595, - "end": 4596, + "start": 4621, + "end": 4622, "replacementText": "3.0", - "line": 180, + "line": 182, "column": 9, - "endLine": 180, + "endLine": 182, "endColumn": 10 } ], @@ -1879,19 +1712,19 @@ "severity": "ERROR" }, { - "line": 181, + "line": 183, "column": 9, - "endLine": 181, + "endLine": 183, "endColumn": 10, "problem": "NumericSemantics", "autofix": [ { - "start": 4613, - "end": 4614, + "start": 4639, + "end": 4640, "replacementText": "3.0", - "line": 181, + "line": 183, "column": 9, - "endLine": 181, + "endLine": 183, "endColumn": 10 } ], @@ -1900,19 +1733,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 5, - "endLine": 182, + "endLine": 184, "endColumn": 19, "problem": "NumericSemantics", "autofix": [ { - "start": 4627, - "end": 4641, - "replacementText": "arr1: number[] = [1, 2, 3]", - "line": 182, + "start": 4657, + "end": 4657, + "replacementText": ": number[]", + "line": 184, "column": 5, - "endLine": 182, + "endLine": 184, "endColumn": 19 } ], @@ -1921,19 +1754,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 13, - "endLine": 182, + "endLine": 184, "endColumn": 14, "problem": "NumericSemantics", "autofix": [ { - "start": 4635, - "end": 4636, + "start": 4661, + "end": 4662, "replacementText": "1.0", - "line": 182, + "line": 184, "column": 13, - "endLine": 182, + "endLine": 184, "endColumn": 14 } ], @@ -1942,19 +1775,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 15, - "endLine": 182, + "endLine": 184, "endColumn": 16, "problem": "NumericSemantics", "autofix": [ { - "start": 4637, - "end": 4638, + "start": 4663, + "end": 4664, "replacementText": "2.0", - "line": 182, + "line": 184, "column": 15, - "endLine": 182, + "endLine": 184, "endColumn": 16 } ], @@ -1963,19 +1796,19 @@ "severity": "ERROR" }, { - "line": 182, + "line": 184, "column": 17, - "endLine": 182, + "endLine": 184, "endColumn": 18, "problem": "NumericSemantics", "autofix": [ { - "start": 4639, - "end": 4640, + "start": 4665, + "end": 4666, "replacementText": "3.0", - "line": 182, + "line": 184, "column": 17, - "endLine": 182, + "endLine": 184, "endColumn": 18 } ], @@ -1984,9 +1817,9 @@ "severity": "ERROR" }, { - "line": 183, + "line": 185, "column": 6, - "endLine": 183, + "endLine": 185, "endColumn": 13, "problem": "RuntimeArrayCheck", "suggest": "", @@ -1994,20 +1827,20 @@ "severity": "ERROR" }, { - "line": 185, + "line": 187, "column": 5, - "endLine": 185, - "endColumn": 12, + "endLine": 187, + "endColumn": 13, "problem": "NumericSemantics", "autofix": [ { - "start": 4670, - "end": 4677, - "replacementText": "a: number = 0.0", - "line": 185, + "start": 4698, + "end": 4698, + "replacementText": ": number", + "line": 187, "column": 5, - "endLine": 185, - "endColumn": 12 + "endLine": 187, + "endColumn": 13 } ], "suggest": "", @@ -2015,19 +1848,19 @@ "severity": "ERROR" }, { - "line": 190, + "line": 192, "column": 10, - "endLine": 190, + "endLine": 192, "endColumn": 11, "problem": "NumericSemantics", "autofix": [ { - "start": 4743, - "end": 4744, + "start": 4772, + "end": 4773, "replacementText": "1.0", - "line": 190, + "line": 192, "column": 10, - "endLine": 190, + "endLine": 192, "endColumn": 11 } ], @@ -2036,19 +1869,19 @@ "severity": "ERROR" }, { - "line": 194, + "line": 196, "column": 10, - "endLine": 194, + "endLine": 196, "endColumn": 11, "problem": "NumericSemantics", "autofix": [ { - "start": 4796, - "end": 4797, + "start": 4825, + "end": 4826, "replacementText": "1.0", - "line": 194, + "line": 196, "column": 10, - "endLine": 194, + "endLine": 196, "endColumn": 11 } ], @@ -2057,9 +1890,9 @@ "severity": "ERROR" }, { - "line": 197, + "line": 199, "column": 1, - "endLine": 197, + "endLine": 199, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -2067,39 +1900,39 @@ "severity": "ERROR" }, { - "line": 199, + "line": 201, "column": 5, - "endLine": 199, - "endColumn": 34, + "endLine": 201, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 199, - "column": 15, - "endLine": 199, - "endColumn": 24, + "line": 201, + "column": 16, + "endLine": 201, + "endColumn": 25, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 21, - "endLine": 200, + "endLine": 202, "endColumn": 22, "problem": "NumericSemantics", "autofix": [ { - "start": 4903, - "end": 4904, + "start": 4933, + "end": 4934, "replacementText": "0.0", - "line": 200, + "line": 202, "column": 21, - "endLine": 200, + "endLine": 202, "endColumn": 22 } ], @@ -2108,19 +1941,19 @@ "severity": "ERROR" }, { - "line": 200, + "line": 202, "column": 28, - "endLine": 200, + "endLine": 202, "endColumn": 31, "problem": "NumericSemantics", "autofix": [ { - "start": 4910, - "end": 4913, + "start": 4940, + "end": 4943, "replacementText": "100.0", - "line": 200, + "line": 202, "column": 28, - "endLine": 200, + "endLine": 202, "endColumn": 31 } ], @@ -2129,20 +1962,20 @@ "severity": "ERROR" }, { - "line": 203, - "column": 52, - "endLine": 203, - "endColumn": 53, + "line": 205, + "column": 53, + "endLine": 205, + "endColumn": 54, "problem": "NumericSemantics", "autofix": [ { - "start": 4991, - "end": 4992, + "start": 5023, + "end": 5024, "replacementText": "6.0", - "line": 203, - "column": 52, - "endLine": 203, - "endColumn": 53 + "line": 205, + "column": 53, + "endLine": 205, + "endColumn": 54 } ], "suggest": "", @@ -2150,20 +1983,20 @@ "severity": "ERROR" }, { - "line": 203, - "column": 55, - "endLine": 203, - "endColumn": 57, + "line": 205, + "column": 56, + "endLine": 205, + "endColumn": 58, "problem": "NumericSemantics", "autofix": [ { - "start": 4994, - "end": 4996, + "start": 5026, + "end": 5028, "replacementText": "86.0", - "line": 203, - "column": 55, - "endLine": 203, - "endColumn": 57 + "line": 205, + "column": 56, + "endLine": 205, + "endColumn": 58 } ], "suggest": "", @@ -2171,9 +2004,9 @@ "severity": "ERROR" }, { - "line": 205, + "line": 207, "column": 42, - "endLine": 205, + "endLine": 207, "endColumn": 51, "problem": "DynamicCtorCall", "suggest": "", @@ -2181,9 +2014,9 @@ "severity": "ERROR" }, { - "line": 212, + "line": 214, "column": 13, - "endLine": 212, + "endLine": 214, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -2191,9 +2024,9 @@ "severity": "ERROR" }, { - "line": 213, + "line": 215, "column": 17, - "endLine": 213, + "endLine": 215, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -2201,9 +2034,9 @@ "severity": "ERROR" }, { - "line": 214, + "line": 216, "column": 17, - "endLine": 214, + "endLine": 216, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -2211,9 +2044,9 @@ "severity": "ERROR" }, { - "line": 215, + "line": 217, "column": 17, - "endLine": 215, + "endLine": 217, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -2221,9 +2054,9 @@ "severity": "ERROR" }, { - "line": 216, + "line": 218, "column": 19, - "endLine": 216, + "endLine": 218, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -2231,9 +2064,9 @@ "severity": "ERROR" }, { - "line": 217, + "line": 219, "column": 18, - "endLine": 217, + "endLine": 219, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -2241,9 +2074,9 @@ "severity": "ERROR" }, { - "line": 218, + "line": 220, "column": 20, - "endLine": 218, + "endLine": 220, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -2251,9 +2084,9 @@ "severity": "ERROR" }, { - "line": 222, + "line": 224, "column": 10, - "endLine": 222, + "endLine": 224, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -2261,9 +2094,9 @@ "severity": "ERROR" }, { - "line": 223, + "line": 225, "column": 11, - "endLine": 223, + "endLine": 225, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -2271,9 +2104,9 @@ "severity": "ERROR" }, { - "line": 224, + "line": 226, "column": 14, - "endLine": 224, + "endLine": 226, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -2281,9 +2114,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 227, "column": 16, - "endLine": 225, + "endLine": 227, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -2291,9 +2124,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 228, "column": 14, - "endLine": 226, + "endLine": 228, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -2301,19 +2134,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 3, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "autofix": [ { - "start": 5469, - "end": 5529, - "replacementText": "public static readonly SIX_MONTH: number = 180 * 24 * 60 * 60 * 1000;", - "line": 230, + "start": 5540, + "end": 5540, + "replacementText": ": number", + "line": 232, "column": 3, - "endLine": 230, + "endLine": 232, "endColumn": 63 } ], @@ -2322,19 +2155,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 38, - "endLine": 230, + "endLine": 232, "endColumn": 41, "problem": "NumericSemantics", "autofix": [ { - "start": 5504, - "end": 5507, + "start": 5543, + "end": 5546, "replacementText": "180.0", - "line": 230, + "line": 232, "column": 38, - "endLine": 230, + "endLine": 232, "endColumn": 41 } ], @@ -2343,19 +2176,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 44, - "endLine": 230, + "endLine": 232, "endColumn": 46, "problem": "NumericSemantics", "autofix": [ { - "start": 5510, - "end": 5512, + "start": 5549, + "end": 5551, "replacementText": "24.0", - "line": 230, + "line": 232, "column": 44, - "endLine": 230, + "endLine": 232, "endColumn": 46 } ], @@ -2364,19 +2197,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 49, - "endLine": 230, + "endLine": 232, "endColumn": 51, "problem": "NumericSemantics", "autofix": [ { - "start": 5515, - "end": 5517, + "start": 5554, + "end": 5556, "replacementText": "60.0", - "line": 230, + "line": 232, "column": 49, - "endLine": 230, + "endLine": 232, "endColumn": 51 } ], @@ -2385,19 +2218,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 54, - "endLine": 230, + "endLine": 232, "endColumn": 56, "problem": "NumericSemantics", "autofix": [ { - "start": 5520, - "end": 5522, + "start": 5559, + "end": 5561, "replacementText": "60.0", - "line": 230, + "line": 232, "column": 54, - "endLine": 230, + "endLine": 232, "endColumn": 56 } ], @@ -2406,19 +2239,19 @@ "severity": "ERROR" }, { - "line": 230, + "line": 232, "column": 59, - "endLine": 230, + "endLine": 232, "endColumn": 63, "problem": "NumericSemantics", "autofix": [ { - "start": 5525, - "end": 5529, + "start": 5564, + "end": 5568, "replacementText": "1000.0", - "line": 230, + "line": 232, "column": 59, - "endLine": 230, + "endLine": 232, "endColumn": 63 } ], @@ -2426,6 +2259,48 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, + { + "line": 236, + "column": 7, + "endLine": 239, + "endColumn": 7, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5618, + "end": 5618, + "replacementText": ": number", + "line": 236, + "column": 7, + "endLine": 239, + "endColumn": 7 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, + { + "line": 238, + "column": 12, + "endLine": 238, + "endColumn": 13, + "problem": "NumericSemantics", + "autofix": [ + { + "start": 5669, + "end": 5670, + "replacementText": "0.0", + "line": 238, + "column": 12, + "endLine": 238, + "endColumn": 13 + } + ], + "suggest": "", + "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", + "severity": "ERROR" + }, { "line": 117, "column": 2, @@ -2437,9 +2312,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2458,9 +2333,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2479,9 +2354,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2500,9 +2375,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2521,9 +2396,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2542,9 +2417,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2553,9 +2428,9 @@ "severity": "ERROR" }, { - "line": 153, + "line": 154, "column": 46, - "endLine": 153, + "endLine": 154, "endColumn": 56, "problem": "UIInterfaceImport", "autofix": [ @@ -2563,9 +2438,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2574,9 +2449,9 @@ "severity": "ERROR" }, { - "line": 154, + "line": 155, "column": 33, - "endLine": 154, + "endLine": 155, "endColumn": 43, "problem": "UIInterfaceImport", "autofix": [ @@ -2584,9 +2459,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], @@ -2595,9 +2470,9 @@ "severity": "ERROR" }, { - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44, "problem": "UIInterfaceImport", "autofix": [ @@ -2605,9 +2480,9 @@ "start": 738, "end": 738, "replacementText": "\r\n\r\nimport {\n Entry,\n Component,\n State,\n RelativeContainer,\n Text,\n AppStorage,\n} from '@kit.ArkUI';\r\n", - "line": 155, + "line": 156, "column": 34, - "endLine": 155, + "endLine": 156, "endColumn": 44 } ], diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.json b/ets2panda/linter/test/main/numeric_semantics.ets.json index 47737941ad04d6a390c617f5cd735c817853aba8..2104782a9f9aedaf0c50e2b0a6d5c1fd03818c0e 100755 --- a/ets2panda/linter/test/main/numeric_semantics.ets.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.json @@ -34,40 +34,20 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, - { - "line": 145, - "column": 50, - "endLine": 145, - "endColumn": 51, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, - { - "line": 152, - "column": 5, - "endLine": 152, - "endColumn": 7, - "problem": "LimitedReturnTypeInference", - "suggest": "", - "rule": "Function return type inference is limited (arkts-no-implicit-return-types)", - "severity": "ERROR" - }, { "line": 152, "column": 9, "endLine": 152, - "endColumn": 12, + "endColumn": 61, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 197, + "line": 199, "column": 1, - "endLine": 197, + "endLine": 199, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -75,10 +55,10 @@ "severity": "ERROR" }, { - "line": 199, + "line": 201, "column": 5, - "endLine": 199, - "endColumn": 34, + "endLine": 201, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets index 43753aa4987f263c914c9445d1ddf7660eb70fb6..b85c4166bf9a570cb41347ef11b238b949da1c2b 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.ets @@ -16,13 +16,13 @@ // TypeScript: treats 'n' as having type number // ArkTS: treats 'n' as having type int to reach max code performance -import { - Entry, - Component, - State, - RelativeContainer, - Text, - AppStorage, +import { + Entry, + Component, + State, + RelativeContainer, + Text, + AppStorage, } from '@kit.ArkUI'; let a: number = 1.0; @@ -112,11 +112,11 @@ function identity(value: T): T { } identity(42.0); -let an_array: number[] = [1.0, 2.0, 3.0] +let an_array: number[] = [1.0,2.0,3.0] -let g: number = an_array[] +let g2: number = an_array[] -const a: number = 1.0 +const a2: number = 1.0 enum Test { A = 1, // 显式赋值为 1 @@ -133,7 +133,7 @@ struct Index2 { readonly c5: number = 0x123; // 16进制 readonly c6: number = 0o123; //8进制 readonly c7: number = 0b101; //2进制 - readonly c8: number[] = [1.0, 2.0, 3.0]; + readonly c8: number[] = [1.0,2.0,3.0] build() { RelativeContainer() { @@ -152,17 +152,15 @@ export class G{ const fingerprintPositionY: number = AppStorage.get(FingerprintConstants.COORDINATE_Y_OF_FINGERPRINT_UD_SCREEN_IN_PX) ?? 0.0; -private doCloseFolderBackgroundAnimation(): (() => { - ({ - openFolderLayout: openFolderLayout, : .getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight, - openFolderLayout: openFolderLayout, : .getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth, - let: let, pos: pos, - pos: pos, - let: let, editModeTranslateY: editModeTranslateY, - if(pos) { }, : .length > 1.0 - }); - return undefined; -})() { +class Layout { + private doCloseFolderBackgroundAnimation(): void { + openFolderLayout.getGridSwiperLayout().bgHeight = openFolderLayout.getBackgroundLayout().closedHeight; + openFolderLayout.getGridSwiperLayout().bgWidth = openFolderLayout.getBackgroundLayout().closedWidth; + + let pos: number[] = [-1.0, -1.0]; + pos = folderLayoutUtil.getFolderComponentCenterPosition(FolderData.getInstance().getOpenedFolder()); + let editModeTranslateY = this.getEditModeTranslateY(pos); + if (pos.length > 1.0) { let translateXForScreenSplit: number = AppStorage.get('translateXForScreenSplit') ?? 0.0 as number; let screenWidth: number = AppStorage.get('screenWidth') as number; let screenHeight: number = AppStorage.get('screenHeight') as number; @@ -174,9 +172,10 @@ private doCloseFolderBackgroundAnimation(): (() => { openFolderLayout.getGridSwiperLayout().bgTranslateY = pos[1] + editModeTranslateY - openFolderLayout.getBackgroundLayout().closedHeight * 0.5 - openFolderLayout.getBackgroundLayout().openedMargin; } + } } -let f: number = 0.0; +let f2: number = 0.0; let b5: number = 0.0; f = b5; // OK @@ -192,12 +191,12 @@ e >>= g1; // OK e &= g1; // OK e = e & 3.0; // OK e = e | 3.0; // OK -let arr1: number[] = [1.0, 2.0, 3.0] +let arr1: number[] = [1.0,2.0,3.0] e += arr1[0]; // OK -let a: number = 0.0; -a = fun1(); -a = fun2()!; +let a3: number = 0.0; +a3 = fun1(); +a3 = fun2()!; function fun1():number{ return 1.0; @@ -209,17 +208,17 @@ function fun2():number|undefined{ import { ArrayList } from "@kit.ArkTS"; -let arr = new ArrayList() +let arr2 = new ArrayList() for (let i:number = 0.0; i < 100.0; i++) { - arr.add(i) + arr2.add(i) } -let cancelIds:ArrayList = arr.subArrayList(6.0, 86.0) -let a: Array = Array.from(cancelIds) -let arr1: Array = Array.from(new ArrayList()) +let cancelIds:ArrayList = arr2.subArrayList(6.0, 86.0) +let arr3: Array = Array.from(cancelIds) +let arr4: Array = Array.from(new ArrayList()) -let a:number = 0.000; +let a4: number = 0.000; -const b:number = 0.000; +const b4: number = 0.000; export enum WalletStageValue { DEFAULT = 0, @@ -240,5 +239,12 @@ export enum AnimationStage { } class C { - public static readonly SIX_MONTH: number = 180.0 * 24.0 * 60.0 * 60.0 * 1000.0; + public static readonly SIX_MONTH: number = 180.0 * 24.0 * 60.0 * 60.0 * 1000.0 } + +function testIndentation(): void { + let a: number = (() => { + console.log('hello'); + return 0.0; + })(); +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json index 09385a376c0a71f5f8ab507066c36cbb0f10a3f5..ca3c08f73a465f3bebee27773db588d4ef40c245 100644 --- a/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json +++ b/ets2panda/linter/test/main/numeric_semantics.ets.migrate.json @@ -26,9 +26,9 @@ }, { "line": 117, - "column": 26, + "column": 27, "endLine": 117, - "endColumn": 26, + "endColumn": 27, "problem": "ArrayIndexExprType", "suggest": "", "rule": "The index expression must be of a numeric type (arkts-array-index-expr-type)", @@ -54,50 +54,40 @@ "rule": "Numeric semantics is different for integer values (arkts-numeric-semantic)", "severity": "ERROR" }, - { - "line": 156, - "column": 6, - "endLine": 156, - "endColumn": 7, - "problem": "ObjectLiteralNoContextType", - "suggest": "", - "rule": "Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals)", - "severity": "ERROR" - }, { "line": 162, "column": 9, "endLine": 162, - "endColumn": 20, - "problem": "ObjectLiteralProperty", + "endColumn": 61, + "problem": "AnyType", "suggest": "", - "rule": "Object literal properties can only contain name-value pairs (arkts-obj-literal-props)", + "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 162, - "column": 9, - "endLine": 162, - "endColumn": 11, - "problem": "InvalidIdentifier", + "line": 171, + "column": 61, + "endLine": 171, + "endColumn": 67, + "problem": "RuntimeArrayCheck", "suggest": "", - "rule": "This keyword cannot be used as identifiers (arkts-invalid-identifier)", + "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, { - "line": 162, - "column": 12, - "endLine": 162, - "endColumn": 15, - "problem": "AnyType", + "line": 172, + "column": 61, + "endLine": 172, + "endColumn": 67, + "problem": "RuntimeArrayCheck", "suggest": "", - "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", + "rule": "Array bound not checked. (arkts-runtime-array-check)", "severity": "ERROR" }, { - "line": 196, + "line": 195, "column": 6, - "endLine": 196, + "endLine": 195, "endColumn": 13, "problem": "RuntimeArrayCheck", "suggest": "", @@ -105,9 +95,9 @@ "severity": "ERROR" }, { - "line": 210, + "line": 209, "column": 1, - "endLine": 210, + "endLine": 209, "endColumn": 40, "problem": "ImportAfterStatement", "suggest": "", @@ -115,29 +105,29 @@ "severity": "ERROR" }, { - "line": 212, + "line": 211, "column": 5, - "endLine": 212, - "endColumn": 34, + "endLine": 211, + "endColumn": 35, "problem": "AnyType", "suggest": "", "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, { - "line": 212, - "column": 15, - "endLine": 212, - "endColumn": 24, + "line": 211, + "column": 16, + "endLine": 211, + "endColumn": 25, "problem": "DynamicCtorCall", "suggest": "", "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, { - "line": 218, + "line": 217, "column": 42, - "endLine": 218, + "endLine": 217, "endColumn": 51, "problem": "DynamicCtorCall", "suggest": "", @@ -145,9 +135,9 @@ "severity": "ERROR" }, { - "line": 225, + "line": 224, "column": 13, - "endLine": 225, + "endLine": 224, "endColumn": 14, "problem": "NumericSemantics", "suggest": "", @@ -155,9 +145,9 @@ "severity": "ERROR" }, { - "line": 226, + "line": 225, "column": 17, - "endLine": 226, + "endLine": 225, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -165,9 +155,9 @@ "severity": "ERROR" }, { - "line": 227, + "line": 226, "column": 17, - "endLine": 227, + "endLine": 226, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -175,9 +165,9 @@ "severity": "ERROR" }, { - "line": 228, + "line": 227, "column": 17, - "endLine": 228, + "endLine": 227, "endColumn": 18, "problem": "NumericSemantics", "suggest": "", @@ -185,9 +175,9 @@ "severity": "ERROR" }, { - "line": 229, + "line": 228, "column": 19, - "endLine": 229, + "endLine": 228, "endColumn": 20, "problem": "NumericSemantics", "suggest": "", @@ -195,9 +185,9 @@ "severity": "ERROR" }, { - "line": 230, + "line": 229, "column": 18, - "endLine": 230, + "endLine": 229, "endColumn": 19, "problem": "NumericSemantics", "suggest": "", @@ -205,9 +195,9 @@ "severity": "ERROR" }, { - "line": 231, + "line": 230, "column": 20, - "endLine": 231, + "endLine": 230, "endColumn": 21, "problem": "NumericSemantics", "suggest": "", @@ -215,9 +205,9 @@ "severity": "ERROR" }, { - "line": 235, + "line": 234, "column": 10, - "endLine": 235, + "endLine": 234, "endColumn": 11, "problem": "NumericSemantics", "suggest": "", @@ -225,9 +215,9 @@ "severity": "ERROR" }, { - "line": 236, + "line": 235, "column": 11, - "endLine": 236, + "endLine": 235, "endColumn": 12, "problem": "NumericSemantics", "suggest": "", @@ -235,9 +225,9 @@ "severity": "ERROR" }, { - "line": 237, + "line": 236, "column": 14, - "endLine": 237, + "endLine": 236, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", @@ -245,9 +235,9 @@ "severity": "ERROR" }, { - "line": 238, + "line": 237, "column": 16, - "endLine": 238, + "endLine": 237, "endColumn": 17, "problem": "NumericSemantics", "suggest": "", @@ -255,9 +245,9 @@ "severity": "ERROR" }, { - "line": 239, + "line": 238, "column": 14, - "endLine": 239, + "endLine": 238, "endColumn": 15, "problem": "NumericSemantics", "suggest": "", diff --git a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json index 9cee3116485dd985f550b19ad95c9d6f09e67846..b1ea53871472befedfd93b89519a5fc67e78c891 100644 --- a/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json +++ b/ets2panda/linter/test/main/numeric_semantics2.ets.autofix.json @@ -53,9 +53,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 702, - "end": 708, - "replacementText": "b: number = 12", + "start": 703, + "end": 703, + "replacementText": ": number", "line": 18, "column": 11, "endLine": 18, @@ -95,9 +95,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 730, - "end": 738, - "replacementText": "c: number = 13.0", + "start": 731, + "end": 731, + "replacementText": ": number", "line": 19, "column": 11, "endLine": 19, @@ -646,9 +646,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2321, - "end": 2327, - "replacementText": "e: number = 15", + "start": 2322, + "end": 2322, + "replacementText": ": number", "line": 86, "column": 9, "endLine": 86, @@ -688,9 +688,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2347, - "end": 2357, - "replacementText": "e1: number = e & 3", + "start": 2349, + "end": 2349, + "replacementText": ": number", "line": 87, "column": 9, "endLine": 87, @@ -730,9 +730,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2378, - "end": 2388, - "replacementText": "e2: number = e | 3", + "start": 2380, + "end": 2380, + "replacementText": ": number", "line": 88, "column": 9, "endLine": 88, diff --git a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json index afb110b1af735f479a6bf5d32fdd9d395ee898b7..432b311d060d6e363d60832bedbeb65972c13771 100644 --- a/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json +++ b/ets2panda/linter/test/main/object_literals_properties.ets.autofix.json @@ -184,9 +184,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 875, - "end": 880, - "replacementText": "x: number = 1", + "start": 876, + "end": 876, + "replacementText": ": number", "line": 31, "column": 5, "endLine": 31, @@ -578,9 +578,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1351, - "end": 1357, - "replacementText": "x2: number = 1", + "start": 1353, + "end": 1353, + "replacementText": ": number", "line": 65, "column": 5, "endLine": 65, @@ -620,9 +620,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1359, - "end": 1365, - "replacementText": "y2: number = 2", + "start": 1361, + "end": 1361, + "replacementText": ": number", "line": 65, "column": 13, "endLine": 65, @@ -662,9 +662,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1367, - "end": 1373, - "replacementText": "z2: number = 3", + "start": 1369, + "end": 1369, + "replacementText": ": number", "line": 65, "column": 21, "endLine": 65, @@ -1023,9 +1023,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1866, - "end": 1874, - "replacementText": "x2: number = 10;", + "start": 1868, + "end": 1868, + "replacementText": ": number", "line": 103, "column": 3, "endLine": 103, @@ -1065,9 +1065,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1877, - "end": 1885, - "replacementText": "y2: number = 20;", + "start": 1879, + "end": 1879, + "replacementText": ": number", "line": 104, "column": 3, "endLine": 104, @@ -1107,9 +1107,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1888, - "end": 1896, - "replacementText": "z2: number = 30;", + "start": 1890, + "end": 1890, + "replacementText": ": number", "line": 105, "column": 3, "endLine": 105, @@ -1271,9 +1271,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2200, - "end": 2208, - "replacementText": "x2: number = 10;", + "start": 2202, + "end": 2202, + "replacementText": ": number", "line": 125, "column": 3, "endLine": 125, @@ -1313,9 +1313,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2211, - "end": 2219, - "replacementText": "y2: number = 20;", + "start": 2213, + "end": 2213, + "replacementText": ": number", "line": 126, "column": 3, "endLine": 126, @@ -1355,9 +1355,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2222, - "end": 2230, - "replacementText": "z2: number = 30;", + "start": 2224, + "end": 2224, + "replacementText": ": number", "line": 127, "column": 3, "endLine": 127, @@ -1438,9 +1438,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2469, - "end": 2474, - "replacementText": "a: number = 1", + "start": 2470, + "end": 2470, + "replacementText": ": number", "line": 141, "column": 7, "endLine": 141, @@ -1480,9 +1480,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 2476, - "end": 2481, - "replacementText": "b: number = 2", + "start": 2477, + "end": 2477, + "replacementText": ": number", "line": 141, "column": 14, "endLine": 141, diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json index 3e8481358e4982d9ace28266eb547a6f83c93d2e..c63d81f2b66aa51101a405779bdcbd7b1e26967f 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json +++ b/ets2panda/linter/test/main/property_access_by_index.ets.autofix.json @@ -63,9 +63,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1158, - "end": 1176, - "replacementText": "ar1: number[] = [1, 2, 3, 4]", + "start": 1161, + "end": 1161, + "replacementText": ": number[]", "line": 33, "column": 5, "endLine": 33, @@ -261,9 +261,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1260, - "end": 1277, - "replacementText": "r0: number = [1, 2, 3][1]", + "start": 1262, + "end": 1262, + "replacementText": ": number", "line": 41, "column": 7, "endLine": 41, @@ -282,9 +282,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1283, - "end": 1303, - "replacementText": "r1: number = [1, 2, 3, 4][0]", + "start": 1285, + "end": 1285, + "replacementText": ": number", "line": 42, "column": 5, "endLine": 42, @@ -323,9 +323,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1422, - "end": 1436, - "replacementText": "array1: number[] = [0, 1]", + "start": 1428, + "end": 1428, + "replacementText": ": number[]", "line": 53, "column": 5, "endLine": 53, @@ -386,9 +386,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1441, - "end": 1461, - "replacementText": "array2: number[] = [1, 2, 3, 4, 5]", + "start": 1447, + "end": 1447, + "replacementText": ": number[]", "line": 54, "column": 5, "endLine": 54, @@ -1420,9 +1420,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 3802, - "end": 3807, - "replacementText": "i: number = 0", + "start": 3803, + "end": 3803, + "replacementText": ": number", "line": 180, "column": 14, "endLine": 180, diff --git a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets index d010da0be00ea18aeeedaa6a5be60ca6ccac41e2..9d61b8611db3da19dc0cfbad2104808d626dda2c 100644 --- a/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets +++ b/ets2panda/linter/test/main/property_access_by_index.ets.migrate.ets @@ -50,8 +50,8 @@ function fobject2(o: Object) { o['k'] } -let array1: number[] = [0.0, 1.0] -let array2: number[] = [1.0, 2.0, 3.0, 4.0, 5.0] +let array1: number[] = [0.0,1.0] +let array2: number[] = [1.0,2.0,3.0,4.0,5.0] let array3: number[] = [1.0,2.0,3.0,4.0,5.0] let array4: Array = [1.0,2.0,3.0,4.0,5.0] let array5 = new Array(10.0) diff --git a/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json index e7463248c2903dda6e2372790d0e73ed95392b24..c69595dde9bb832ed87a31fb18b06db442de1a30 100644 --- a/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json +++ b/ets2panda/linter/test/main/repeat_virtualscroll.ets.autofix.json @@ -22,9 +22,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 739, - "end": 744, - "replacementText": "i: number = 0", + "start": 740, + "end": 740, + "replacementText": ": number", "line": 22, "column": 14, "endLine": 22, diff --git a/ets2panda/linter/test/main/void_operator.ets.autofix.json b/ets2panda/linter/test/main/void_operator.ets.autofix.json index 517ba65f3afc2c9d7aaf7505eed7645eefb1a281..12662791b0d03735dd0cac102b5a5845e0a3a21b 100644 --- a/ets2panda/linter/test/main/void_operator.ets.autofix.json +++ b/ets2panda/linter/test/main/void_operator.ets.autofix.json @@ -744,9 +744,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1090, - "end": 1095, - "replacementText": "a: number = 1", + "start": 1091, + "end": 1091, + "replacementText": ": number", "line": 55, "column": 7, "endLine": 55, @@ -807,9 +807,9 @@ "problem": "NumericSemantics", "autofix": [ { - "start": 1116, - "end": 1129, - "replacementText": "b: number[] = [1, 2, 3]", + "start": 1117, + "end": 1117, + "replacementText": ": number[]", "line": 58, "column": 7, "endLine": 58,