From ae25971b81053462b8836fc03ec2dfabf17c052d Mon Sep 17 00:00:00 2001 From: Vsevolod Pukhov Date: Wed, 23 Aug 2023 15:38:28 +0300 Subject: [PATCH] [ArkTS Linter] Remove arrow functions omitted params check Signed-off-by: Vsevolod Pukhov --- linter-4.2/src/Problems.ts | 3 +- linter-4.2/src/TypeScriptLinter.ts | 45 +---------------- linter-4.2/src/TypeScriptLinterConfig.ts | 1 - .../test/arkui_decorators.ts.autofix.json | 30 ----------- .../test/arkui_decorators.ts.strict.json | 25 ---------- linter-4.2/test/functions.ts.autofix.json | 50 ++++--------------- linter-4.2/test/functions.ts.strict.json | 25 ---------- linter-4.2/test/inferred_type.ts.strict.json | 5 -- .../test/prototype_assignment.ts.autofix.json | 12 ----- .../test/prototype_assignment.ts.strict.json | 10 ---- linter-4.2/test/types.ts.autofix.json | 13 ----- linter-4.2/test/types.ts.strict.json | 5 -- linter/src/FaultAttrs.ts | 1 - linter/src/FaultDesc.ts | 1 - linter/src/Problems.ts | 2 +- linter/src/TypeScriptLinter.ts | 46 +---------------- linter/test/arkui_decorators.ts.autofix.json | 30 ----------- linter/test/arkui_decorators.ts.strict.json | 25 ---------- linter/test/functions.ts.autofix.json | 50 ++++--------------- linter/test/functions.ts.strict.json | 25 ---------- linter/test/inferred_type.ts.strict.json | 5 -- .../test/prototype_assignment.ts.autofix.json | 12 ----- .../test/prototype_assignment.ts.strict.json | 10 ---- linter/test/types.ts.autofix.json | 13 ----- linter/test/types.ts.strict.json | 5 -- 25 files changed, 26 insertions(+), 423 deletions(-) diff --git a/linter-4.2/src/Problems.ts b/linter-4.2/src/Problems.ts index 6c2ff24e4..57858c6c3 100644 --- a/linter-4.2/src/Problems.ts +++ b/linter-4.2/src/Problems.ts @@ -20,7 +20,7 @@ export enum FaultID { ThrowStatement, IndexedAccessType, UnknownType, ForInStatement, InOperator, KeyOfOperator, ImportFromPath, FunctionExpression, IntersectionType, ObjectTypeLiteral, AddWithWrongType, CommaOperator, LimitedReturnTypeInference, - ArrowFunctionWithOmittedTypes, LambdaWithTypeParameters, ClassExpression, DestructuringAssignment, + LambdaWithTypeParameters, ClassExpression, DestructuringAssignment, DestructuringDeclaration, ForOfNonArray, VarDeclaration, CatchWithUnsupportedType, DeleteOperator, DeclWithDuplicateName, UnaryArithmNotNumber, ConstructorType, ConstructorIface, ConstructorFuncs, CallSignature, TypeAssertion, PrivateIdentifier, LocalFunction, @@ -72,7 +72,6 @@ faultsAttrs[FaultID.RegexLiteral] = {cookBookRef: '37',}; faultsAttrs[FaultID.ObjectLiteralNoContextType] = {cookBookRef: '38',}; faultsAttrs[FaultID.ObjectTypeLiteral] = {cookBookRef: '40',}; faultsAttrs[FaultID.ArrayLiteralNoContextType] = {cookBookRef: '43',}; -faultsAttrs[FaultID.ArrowFunctionWithOmittedTypes] = {migratable: true, cookBookRef: '45',}; faultsAttrs[FaultID.FunctionExpression] = {migratable: true, cookBookRef: '46',}; faultsAttrs[FaultID.LambdaWithTypeParameters] = {migratable: true, cookBookRef: '49',}; faultsAttrs[FaultID.ClassExpression] = {migratable: true, cookBookRef: '50',}; diff --git a/linter-4.2/src/TypeScriptLinter.ts b/linter-4.2/src/TypeScriptLinter.ts index dafd72b8f..516d074ca 100644 --- a/linter-4.2/src/TypeScriptLinter.ts +++ b/linter-4.2/src/TypeScriptLinter.ts @@ -704,20 +704,16 @@ export class TypeScriptLinter { let containsThis = this.functionContainsThis(funcExpr.body); let isGeneric = funcExpr.typeParameters !== undefined && funcExpr.typeParameters.length > 0; - let newParams = this.handleMissingParameterTypes(funcExpr); - let [hasUnfixableReturnType, newRetTypeNode] = this.handleMissingReturnType(funcExpr); - let autofixable = !isGeneric && !isGenerator && !containsThis && - newParams && !hasUnfixableReturnType; + let autofixable = !isGeneric && !isGenerator && !containsThis && !hasUnfixableReturnType; let autofix: Autofix[] | undefined; if (autofixable && this.autofixesInfo.shouldAutofix(node, FaultID.FunctionExpression)) { - autofix = [ Autofixer.fixFunctionExpression(funcExpr, newParams, newRetTypeNode) ]; + autofix = [ Autofixer.fixFunctionExpression(funcExpr, funcExpr.parameters, newRetTypeNode) ]; } this.incrementCounters(node, FaultID.FunctionExpression, autofixable, autofix); - if (!newParams) this.incrementCounters(funcExpr, FaultID.ArrowFunctionWithOmittedTypes, false); if (isGeneric) this.incrementCounters(funcExpr, FaultID.LambdaWithTypeParameters); if (isGenerator) this.incrementCounters(funcExpr, FaultID.GeneratorFunction); if (containsThis) this.incrementCounters(funcExpr, FaultID.FunctionContainsThis); @@ -732,8 +728,6 @@ export class TypeScriptLinter { const contextType = this.tsTypeChecker.getContextualType(arrowFunc); if (!(contextType && this.tsUtils.isLibraryType(contextType))) { - this.handleMissingParameterTypes(arrowFunc); - if (!arrowFunc.type) this.handleMissingReturnType(arrowFunc); if (arrowFunc.typeParameters && arrowFunc.typeParameters.length > 0) @@ -741,41 +735,6 @@ export class TypeScriptLinter { } } - private handleMissingParameterTypes(signDecl: ts.SignatureDeclaration): - ts.NodeArray | undefined { - let hasOmittedType = false; - let autofixable = true; - let autofix: Autofix[] | undefined; - let isFuncExpr = signDecl.kind === ts.SyntaxKind.FunctionExpression; - let newParams: ts.ParameterDeclaration[] = []; - for (const param of signDecl.parameters) { - if (isFuncExpr) newParams.push(param); - if (param.type) continue; - - hasOmittedType = true; - let paramType = this.tsTypeChecker.getTypeAtLocation(param); - let paramTypeNode = this.tsTypeChecker.typeToTypeNode(paramType, param, ts.NodeBuilderFlags.None); - if (!paramType || this.tsUtils.isUnsupportedType(paramType) || !paramTypeNode) { - autofixable = false; - continue; - } - - if (isFuncExpr) { - let newParam = Autofixer.fixParamWithoutType(param, paramTypeNode, true) as ts.ParameterDeclaration; - newParams[newParams.length-1] = newParam; - } else if (this.autofixesInfo.shouldAutofix(signDecl, FaultID.ArrowFunctionWithOmittedTypes)) { - if (!autofix) autofix = []; - autofix.push(Autofixer.fixParamWithoutType(param, paramTypeNode) as Autofix); - } - } - // Don't report here if in function expression context. - // See handleFunctionExpression for details. - if (hasOmittedType && !isFuncExpr) - this.incrementCounters(signDecl, FaultID.ArrowFunctionWithOmittedTypes, autofixable, autofix); - - return isFuncExpr && autofixable ? ts.factory.createNodeArray(newParams) : undefined; - } - private handleClassExpression(node: ts.Node) { let tsClassExpr = node as ts.ClassExpression; this.incrementCounters(node, FaultID.ClassExpression); diff --git a/linter-4.2/src/TypeScriptLinterConfig.ts b/linter-4.2/src/TypeScriptLinterConfig.ts index 5b8bcdb29..1a027488f 100644 --- a/linter-4.2/src/TypeScriptLinterConfig.ts +++ b/linter-4.2/src/TypeScriptLinterConfig.ts @@ -63,7 +63,6 @@ export class LinterConfig { // LinterConfig.nodeDesc[FaultID.BitOpWithWrongType] = 'bit operation with wrong operand'; LinterConfig.nodeDesc[FaultID.CommaOperator] = 'comma operator'; LinterConfig.nodeDesc[FaultID.LimitedReturnTypeInference] = 'Functions with limited return type inference'; - LinterConfig.nodeDesc[FaultID.ArrowFunctionWithOmittedTypes] = 'Arrow functions with omitted parameter types'; LinterConfig.nodeDesc[FaultID.LambdaWithTypeParameters] = 'Lambda function with type parameters'; LinterConfig.nodeDesc[FaultID.ClassExpression] = 'Class expressions'; LinterConfig.nodeDesc[FaultID.DestructuringAssignment] = 'Destructuring assignments'; diff --git a/linter-4.2/test/arkui_decorators.ts.autofix.json b/linter-4.2/test/arkui_decorators.ts.autofix.json index e02cafd75..ce00ce37a 100644 --- a/linter-4.2/test/arkui_decorators.ts.autofix.json +++ b/linter-4.2/test/arkui_decorators.ts.autofix.json @@ -32,12 +32,6 @@ "problem": "IntersectionType", "autofixable": false }, - { - "line": 22, - "column": 32, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 22, "column": 33, @@ -50,12 +44,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 24, - "column": 43, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 24, "column": 44, @@ -68,12 +56,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 29, - "column": 31, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 29, "column": 32, @@ -86,12 +68,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 38, - "column": 39, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 38, "column": 40, @@ -104,12 +80,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 39, - "column": 62, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 39, "column": 63, diff --git a/linter-4.2/test/arkui_decorators.ts.strict.json b/linter-4.2/test/arkui_decorators.ts.strict.json index 2c1b9c82e..47743d022 100644 --- a/linter-4.2/test/arkui_decorators.ts.strict.json +++ b/linter-4.2/test/arkui_decorators.ts.strict.json @@ -29,11 +29,6 @@ "column": 30, "problem": "IntersectionType" }, - { - "line": 22, - "column": 32, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 22, "column": 33, @@ -44,11 +39,6 @@ "column": 36, "problem": "AnyType" }, - { - "line": 24, - "column": 43, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 24, "column": 44, @@ -59,11 +49,6 @@ "column": 47, "problem": "AnyType" }, - { - "line": 29, - "column": 31, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 29, "column": 32, @@ -74,11 +59,6 @@ "column": 35, "problem": "AnyType" }, - { - "line": 38, - "column": 39, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 38, "column": 40, @@ -89,11 +69,6 @@ "column": 43, "problem": "AnyType" }, - { - "line": 39, - "column": 62, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 39, "column": 63, diff --git a/linter-4.2/test/functions.ts.autofix.json b/linter-4.2/test/functions.ts.autofix.json index c9dc613cc..b2f9e5af6 100644 --- a/linter-4.2/test/functions.ts.autofix.json +++ b/linter-4.2/test/functions.ts.autofix.json @@ -61,13 +61,14 @@ "line": 49, "column": 20, "problem": "FunctionExpression", - "autofixable": false - }, - { - "line": 49, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false + "autofixable": true, + "autofix": [ + { + "start": 1258, + "end": 1313, + "replacementText": "(x: number, y): number => {\r\n return x * y;\r\n}" + } + ] }, { "line": 49, @@ -155,7 +156,7 @@ { "start": 1762, "end": 1798, - "replacementText": "(e: number) => {\r\n return e * 2;\r\n}" + "replacementText": "(e) => {\r\n return e * 2;\r\n}" } ] }, @@ -168,7 +169,7 @@ { "start": 1829, "end": 1871, - "replacementText": "(x: number) => {\r\n return x % 2 === 0;\r\n}" + "replacementText": "(x) => {\r\n return x % 2 === 0;\r\n}" } ] }, @@ -184,49 +185,18 @@ "problem": "LambdaWithTypeParameters", "autofixable": false }, - { - "line": 93, - "column": 18, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 93, "column": 19, "problem": "AnyType", "autofixable": false }, - { - "line": 95, - "column": 16, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 95, "column": 17, "problem": "AnyType", "autofixable": false }, - { - "line": 96, - "column": 42, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": true, - "autofix": [ - { - "start": 2233, - "end": 2234, - "replacementText": "x: number" - } - ] - }, - { - "line": 98, - "column": 15, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 98, "column": 27, diff --git a/linter-4.2/test/functions.ts.strict.json b/linter-4.2/test/functions.ts.strict.json index 67f1ad7a4..641959895 100644 --- a/linter-4.2/test/functions.ts.strict.json +++ b/linter-4.2/test/functions.ts.strict.json @@ -49,11 +49,6 @@ "column": 20, "problem": "FunctionExpression" }, - { - "line": 49, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 49, "column": 41, @@ -109,36 +104,16 @@ "column": 19, "problem": "LambdaWithTypeParameters" }, - { - "line": 93, - "column": 18, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 93, "column": 19, "problem": "AnyType" }, - { - "line": 95, - "column": 16, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 95, "column": 17, "problem": "AnyType" }, - { - "line": 96, - "column": 42, - "problem": "ArrowFunctionWithOmittedTypes" - }, - { - "line": 98, - "column": 15, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 98, "column": 27, diff --git a/linter-4.2/test/inferred_type.ts.strict.json b/linter-4.2/test/inferred_type.ts.strict.json index 45bfefa9e..928645dd6 100644 --- a/linter-4.2/test/inferred_type.ts.strict.json +++ b/linter-4.2/test/inferred_type.ts.strict.json @@ -39,11 +39,6 @@ "column": 14, "problem": "AnyType" }, - { - "line": 28, - "column": 11, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 28, "column": 23, diff --git a/linter-4.2/test/prototype_assignment.ts.autofix.json b/linter-4.2/test/prototype_assignment.ts.autofix.json index 5eec59da4..ca852403d 100644 --- a/linter-4.2/test/prototype_assignment.ts.autofix.json +++ b/linter-4.2/test/prototype_assignment.ts.autofix.json @@ -26,12 +26,6 @@ "problem": "FunctionExpression", "autofixable": false }, - { - "line": 17, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 17, "column": 20, @@ -68,12 +62,6 @@ "problem": "FunctionExpression", "autofixable": false }, - { - "line": 27, - "column": 26, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 27, "column": 26, diff --git a/linter-4.2/test/prototype_assignment.ts.strict.json b/linter-4.2/test/prototype_assignment.ts.strict.json index afe808d0f..52a5b06fa 100644 --- a/linter-4.2/test/prototype_assignment.ts.strict.json +++ b/linter-4.2/test/prototype_assignment.ts.strict.json @@ -24,11 +24,6 @@ "column": 20, "problem": "FunctionExpression" }, - { - "line": 17, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 17, "column": 20, @@ -59,11 +54,6 @@ "column": 26, "problem": "FunctionExpression" }, - { - "line": 27, - "column": 26, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 27, "column": 26, diff --git a/linter-4.2/test/types.ts.autofix.json b/linter-4.2/test/types.ts.autofix.json index 4b172f052..df792c988 100644 --- a/linter-4.2/test/types.ts.autofix.json +++ b/linter-4.2/test/types.ts.autofix.json @@ -340,19 +340,6 @@ "problem": "LocalFunction", "autofixable": false }, - { - "line": 139, - "column": 22, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": true, - "autofix": [ - { - "start": 3168, - "end": 3169, - "replacementText": "x: T" - } - ] - }, { "line": 157, "column": 5, diff --git a/linter-4.2/test/types.ts.strict.json b/linter-4.2/test/types.ts.strict.json index c37728933..ef1caa5f5 100644 --- a/linter-4.2/test/types.ts.strict.json +++ b/linter-4.2/test/types.ts.strict.json @@ -239,11 +239,6 @@ "column": 3, "problem": "LocalFunction" }, - { - "line": 139, - "column": 22, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 157, "column": 5, diff --git a/linter/src/FaultAttrs.ts b/linter/src/FaultAttrs.ts index 5669bf6ff..0fab4b6c2 100644 --- a/linter/src/FaultAttrs.ts +++ b/linter/src/FaultAttrs.ts @@ -50,7 +50,6 @@ faultsAttrs[FaultID.RegexLiteral] = {cookBookRef: '37',}; faultsAttrs[FaultID.ObjectLiteralNoContextType] = {cookBookRef: '38',}; faultsAttrs[FaultID.ObjectTypeLiteral] = {cookBookRef: '40',}; faultsAttrs[FaultID.ArrayLiteralNoContextType] = {cookBookRef: '43',}; -faultsAttrs[FaultID.ArrowFunctionWithOmittedTypes] = {migratable: true, cookBookRef: '45',}; faultsAttrs[FaultID.FunctionExpression] = {migratable: true, cookBookRef: '46',}; faultsAttrs[FaultID.LambdaWithTypeParameters] = {migratable: true, cookBookRef: '49',}; faultsAttrs[FaultID.ClassExpression] = {migratable: true, cookBookRef: '50',}; diff --git a/linter/src/FaultDesc.ts b/linter/src/FaultDesc.ts index eab13903d..ab625c7da 100644 --- a/linter/src/FaultDesc.ts +++ b/linter/src/FaultDesc.ts @@ -47,7 +47,6 @@ faultDesc[FaultID.ObjectTypeLiteral] = 'Object type literals'; faultDesc[FaultID.AddWithWrongType] = 'binary "+" with wrong operand'; faultDesc[FaultID.CommaOperator] = 'comma operator'; faultDesc[FaultID.LimitedReturnTypeInference] = 'Functions with limited return type inference'; -faultDesc[FaultID.ArrowFunctionWithOmittedTypes] = 'Arrow functions with omitted parameter types'; faultDesc[FaultID.LambdaWithTypeParameters] = 'Lambda function with type parameters'; faultDesc[FaultID.ClassExpression] = 'Class expressions'; faultDesc[FaultID.DestructuringAssignment] = 'Destructuring assignments'; diff --git a/linter/src/Problems.ts b/linter/src/Problems.ts index 658bb159a..8aaa7d6ae 100644 --- a/linter/src/Problems.ts +++ b/linter/src/Problems.ts @@ -20,7 +20,7 @@ export enum FaultID { ThrowStatement, IndexedAccessType, UnknownType, ForInStatement, InOperator, KeyOfOperator, ImportFromPath, FunctionExpression, IntersectionType, ObjectTypeLiteral, AddWithWrongType, CommaOperator, LimitedReturnTypeInference, - ArrowFunctionWithOmittedTypes, LambdaWithTypeParameters, ClassExpression, DestructuringAssignment, + LambdaWithTypeParameters, ClassExpression, DestructuringAssignment, DestructuringDeclaration, ForOfNonArray, VarDeclaration, CatchWithUnsupportedType, DeleteOperator, DeclWithDuplicateName, UnaryArithmNotNumber, ConstructorType, ConstructorIface, ConstructorFuncs, CallSignature, TypeAssertion, PrivateIdentifier, LocalFunction, diff --git a/linter/src/TypeScriptLinter.ts b/linter/src/TypeScriptLinter.ts index 0c9ef14d4..b8ed5e104 100644 --- a/linter/src/TypeScriptLinter.ts +++ b/linter/src/TypeScriptLinter.ts @@ -683,17 +683,13 @@ export class TypeScriptLinter { let isGenerator = funcExpr.asteriskToken !== undefined; let containsThis = functionContainsThis(funcExpr.body); let isGeneric = funcExpr.typeParameters !== undefined && funcExpr.typeParameters.length > 0; - let newParams = this.handleMissingParameterTypes(funcExpr); let [hasUnfixableReturnType, newRetTypeNode] = this.handleMissingReturnType(funcExpr); - let autofixable = !isGeneric && !isGenerator && !containsThis && newParams && !hasUnfixableReturnType; + let autofixable = !isGeneric && !isGenerator && !containsThis && !hasUnfixableReturnType; let autofix: Autofix[] | undefined; if (autofixable && this.autofixesInfo.shouldAutofix(node, FaultID.FunctionExpression)) { - autofix = [ Autofixer.fixFunctionExpression(funcExpr, newParams, newRetTypeNode) ]; + autofix = [ Autofixer.fixFunctionExpression(funcExpr, funcExpr.parameters, newRetTypeNode) ]; } this.incrementCounters(node, FaultID.FunctionExpression, autofixable, autofix); - if (!newParams) { - this.incrementCounters(funcExpr, FaultID.ArrowFunctionWithOmittedTypes, false); - } if (isGeneric) { this.incrementCounters(funcExpr, FaultID.LambdaWithTypeParameters); } @@ -715,7 +711,6 @@ export class TypeScriptLinter { } const contextType = this.tsTypeChecker.getContextualType(arrowFunc); if (!(contextType && this.tsUtils.isLibraryType(contextType))) { - this.handleMissingParameterTypes(arrowFunc); if (!arrowFunc.type) { this.handleMissingReturnType(arrowFunc); } @@ -725,43 +720,6 @@ export class TypeScriptLinter { } } - private handleMissingParameterTypes(signDecl: ts.SignatureDeclaration): - ts.NodeArray | undefined { - let hasOmittedType = false; - let autofixable = true; - let autofix: Autofix[] | undefined; - let isFuncExpr = signDecl.kind === ts.SyntaxKind.FunctionExpression; - let newParams: ts.ParameterDeclaration[] = []; - for (const param of signDecl.parameters) { - if (isFuncExpr) { - newParams.push(param); - } - if (param.type) { - continue; - } - hasOmittedType = true; - let paramType = this.tsTypeChecker.getTypeAtLocation(param); - let paramTypeNode = this.tsTypeChecker.typeToTypeNode(paramType, param, ts.NodeBuilderFlags.None); - if (!paramType || this.tsUtils.isUnsupportedType(paramType) || !paramTypeNode) { - autofixable = false; - continue; - } - if (isFuncExpr) { - let newParam = Autofixer.fixParamWithoutType(param, paramTypeNode, true) as ts.ParameterDeclaration; - newParams[newParams.length-1] = newParam; - } else if (this.autofixesInfo.shouldAutofix(signDecl, FaultID.ArrowFunctionWithOmittedTypes)) { - if (!autofix) autofix = []; - autofix.push(Autofixer.fixParamWithoutType(param, paramTypeNode) as Autofix); - } - } - // Don't report here if in function expression context. - // See handleFunctionExpression for details. - if (hasOmittedType && !isFuncExpr) { - this.incrementCounters(signDecl, FaultID.ArrowFunctionWithOmittedTypes, autofixable, autofix); - } - return isFuncExpr && autofixable ? ts.factory.createNodeArray(newParams) : undefined; - } - private handleClassExpression(node: ts.Node) { let tsClassExpr = node as ts.ClassExpression; this.incrementCounters(node, FaultID.ClassExpression); diff --git a/linter/test/arkui_decorators.ts.autofix.json b/linter/test/arkui_decorators.ts.autofix.json index e02cafd75..ce00ce37a 100644 --- a/linter/test/arkui_decorators.ts.autofix.json +++ b/linter/test/arkui_decorators.ts.autofix.json @@ -32,12 +32,6 @@ "problem": "IntersectionType", "autofixable": false }, - { - "line": 22, - "column": 32, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 22, "column": 33, @@ -50,12 +44,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 24, - "column": 43, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 24, "column": 44, @@ -68,12 +56,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 29, - "column": 31, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 29, "column": 32, @@ -86,12 +68,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 38, - "column": 39, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 38, "column": 40, @@ -104,12 +80,6 @@ "problem": "AnyType", "autofixable": false }, - { - "line": 39, - "column": 62, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 39, "column": 63, diff --git a/linter/test/arkui_decorators.ts.strict.json b/linter/test/arkui_decorators.ts.strict.json index 2c1b9c82e..47743d022 100644 --- a/linter/test/arkui_decorators.ts.strict.json +++ b/linter/test/arkui_decorators.ts.strict.json @@ -29,11 +29,6 @@ "column": 30, "problem": "IntersectionType" }, - { - "line": 22, - "column": 32, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 22, "column": 33, @@ -44,11 +39,6 @@ "column": 36, "problem": "AnyType" }, - { - "line": 24, - "column": 43, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 24, "column": 44, @@ -59,11 +49,6 @@ "column": 47, "problem": "AnyType" }, - { - "line": 29, - "column": 31, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 29, "column": 32, @@ -74,11 +59,6 @@ "column": 35, "problem": "AnyType" }, - { - "line": 38, - "column": 39, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 38, "column": 40, @@ -89,11 +69,6 @@ "column": 43, "problem": "AnyType" }, - { - "line": 39, - "column": 62, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 39, "column": 63, diff --git a/linter/test/functions.ts.autofix.json b/linter/test/functions.ts.autofix.json index c9dc613cc..b2f9e5af6 100755 --- a/linter/test/functions.ts.autofix.json +++ b/linter/test/functions.ts.autofix.json @@ -61,13 +61,14 @@ "line": 49, "column": 20, "problem": "FunctionExpression", - "autofixable": false - }, - { - "line": 49, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false + "autofixable": true, + "autofix": [ + { + "start": 1258, + "end": 1313, + "replacementText": "(x: number, y): number => {\r\n return x * y;\r\n}" + } + ] }, { "line": 49, @@ -155,7 +156,7 @@ { "start": 1762, "end": 1798, - "replacementText": "(e: number) => {\r\n return e * 2;\r\n}" + "replacementText": "(e) => {\r\n return e * 2;\r\n}" } ] }, @@ -168,7 +169,7 @@ { "start": 1829, "end": 1871, - "replacementText": "(x: number) => {\r\n return x % 2 === 0;\r\n}" + "replacementText": "(x) => {\r\n return x % 2 === 0;\r\n}" } ] }, @@ -184,49 +185,18 @@ "problem": "LambdaWithTypeParameters", "autofixable": false }, - { - "line": 93, - "column": 18, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 93, "column": 19, "problem": "AnyType", "autofixable": false }, - { - "line": 95, - "column": 16, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 95, "column": 17, "problem": "AnyType", "autofixable": false }, - { - "line": 96, - "column": 42, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": true, - "autofix": [ - { - "start": 2233, - "end": 2234, - "replacementText": "x: number" - } - ] - }, - { - "line": 98, - "column": 15, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 98, "column": 27, diff --git a/linter/test/functions.ts.strict.json b/linter/test/functions.ts.strict.json index 67f1ad7a4..641959895 100644 --- a/linter/test/functions.ts.strict.json +++ b/linter/test/functions.ts.strict.json @@ -49,11 +49,6 @@ "column": 20, "problem": "FunctionExpression" }, - { - "line": 49, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 49, "column": 41, @@ -109,36 +104,16 @@ "column": 19, "problem": "LambdaWithTypeParameters" }, - { - "line": 93, - "column": 18, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 93, "column": 19, "problem": "AnyType" }, - { - "line": 95, - "column": 16, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 95, "column": 17, "problem": "AnyType" }, - { - "line": 96, - "column": 42, - "problem": "ArrowFunctionWithOmittedTypes" - }, - { - "line": 98, - "column": 15, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 98, "column": 27, diff --git a/linter/test/inferred_type.ts.strict.json b/linter/test/inferred_type.ts.strict.json index 45bfefa9e..928645dd6 100644 --- a/linter/test/inferred_type.ts.strict.json +++ b/linter/test/inferred_type.ts.strict.json @@ -39,11 +39,6 @@ "column": 14, "problem": "AnyType" }, - { - "line": 28, - "column": 11, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 28, "column": 23, diff --git a/linter/test/prototype_assignment.ts.autofix.json b/linter/test/prototype_assignment.ts.autofix.json index 5eec59da4..ca852403d 100755 --- a/linter/test/prototype_assignment.ts.autofix.json +++ b/linter/test/prototype_assignment.ts.autofix.json @@ -26,12 +26,6 @@ "problem": "FunctionExpression", "autofixable": false }, - { - "line": 17, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 17, "column": 20, @@ -68,12 +62,6 @@ "problem": "FunctionExpression", "autofixable": false }, - { - "line": 27, - "column": 26, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": false - }, { "line": 27, "column": 26, diff --git a/linter/test/prototype_assignment.ts.strict.json b/linter/test/prototype_assignment.ts.strict.json index afe808d0f..52a5b06fa 100644 --- a/linter/test/prototype_assignment.ts.strict.json +++ b/linter/test/prototype_assignment.ts.strict.json @@ -24,11 +24,6 @@ "column": 20, "problem": "FunctionExpression" }, - { - "line": 17, - "column": 20, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 17, "column": 20, @@ -59,11 +54,6 @@ "column": 26, "problem": "FunctionExpression" }, - { - "line": 27, - "column": 26, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 27, "column": 26, diff --git a/linter/test/types.ts.autofix.json b/linter/test/types.ts.autofix.json index 4b172f052..df792c988 100644 --- a/linter/test/types.ts.autofix.json +++ b/linter/test/types.ts.autofix.json @@ -340,19 +340,6 @@ "problem": "LocalFunction", "autofixable": false }, - { - "line": 139, - "column": 22, - "problem": "ArrowFunctionWithOmittedTypes", - "autofixable": true, - "autofix": [ - { - "start": 3168, - "end": 3169, - "replacementText": "x: T" - } - ] - }, { "line": 157, "column": 5, diff --git a/linter/test/types.ts.strict.json b/linter/test/types.ts.strict.json index c37728933..ef1caa5f5 100644 --- a/linter/test/types.ts.strict.json +++ b/linter/test/types.ts.strict.json @@ -239,11 +239,6 @@ "column": 3, "problem": "LocalFunction" }, - { - "line": 139, - "column": 22, - "problem": "ArrowFunctionWithOmittedTypes" - }, { "line": 157, "column": 5, -- Gitee