From 9b0a46466278669a0ea095f03b9e417b8b740600 Mon Sep 17 00:00:00 2001 From: Raif Mirza Erten Date: Fri, 22 Aug 2025 11:13:48 +0300 Subject: [PATCH 1/6] arkts-no-ts-like-smart-type for loop fix Description: fix missed case for "for loop" Issue: ICU9UE Signed-off-by: Raif Mirza Erten --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 86 ++++++++++----- .../test/main/no_ts_like_smart_type.ets | 62 ++++++++++- .../no_ts_like_smart_type.ets.arkts2.json | 44 +++++--- .../test/main/no_ts_like_smart_type.ets.json | 104 +++++++++++++++--- 4 files changed, 240 insertions(+), 56 deletions(-) mode change 100755 => 100644 ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json mode change 100755 => 100644 ets2panda/linter/test/main/no_ts_like_smart_type.ets.json diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index c4edcff3b3..cd882dff73 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -2018,40 +2018,38 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleNoDeprecatedApi(node); if (!this.options.arkts2) { - this.handleLiteralAsPropertyNameForPropertyAssignment(node); - } + this.handleLiteralAsPropertyNameForPropertyAssignment(node); + } } private handleLiteralAsPropertyNameForPropertyAssignment(node: ts.PropertyAssignment): void { - const propName = node.name; - if (!propName || !(ts.isNumericLiteral(propName) || ts.isStringLiteral(propName))) { - return; - } - - /* - * We can use literals as property names only when creating Record or any interop instances. - * We can also initialize with constant string literals. - * Assignment with string enum values is handled in handleComputedPropertyName - */ - let isRecordObjectInitializer = false; - let isLibraryType = false; - let isDynamic = false; - const objectLiteralType = this.tsTypeChecker.getContextualType(node.parent); + const propName = node.name; + if (!propName || !(ts.isNumericLiteral(propName) || ts.isStringLiteral(propName))) { + return; + } - if (objectLiteralType) { - isRecordObjectInitializer = this.tsUtils.checkTypeSet(objectLiteralType, this.tsUtils.isStdRecordType); - isLibraryType = this.tsUtils.isLibraryType(objectLiteralType); + /* + * We can use literals as property names only when creating Record or any interop instances. + * We can also initialize with constant string literals. + * Assignment with string enum values is handled in handleComputedPropertyName + */ + let isRecordObjectInitializer = false; + let isLibraryType = false; + let isDynamic = false; + const objectLiteralType = this.tsTypeChecker.getContextualType(node.parent); - } + if (objectLiteralType) { + isRecordObjectInitializer = this.tsUtils.checkTypeSet(objectLiteralType, this.tsUtils.isStdRecordType); + isLibraryType = this.tsUtils.isLibraryType(objectLiteralType); + } - isDynamic = isLibraryType || this.tsUtils.isDynamicLiteralInitializer(node.parent); + isDynamic = isLibraryType || this.tsUtils.isDynamicLiteralInitializer(node.parent); - if (!isRecordObjectInitializer && !isDynamic) { - const autofix = this.autofixer?.fixLiteralAsPropertyNamePropertyAssignment(node); - this.incrementCounters(node.name, FaultID.LiteralAsPropertyName, autofix); + if (!isRecordObjectInitializer && !isDynamic) { + const autofix = this.autofixer?.fixLiteralAsPropertyNamePropertyAssignment(node); + this.incrementCounters(node.name, FaultID.LiteralAsPropertyName, autofix); + } } -} - private static getAllClassesFromSourceFile(sourceFile: ts.SourceFile): ts.ClassDeclaration[] { const allClasses: ts.ClassDeclaration[] = []; @@ -12457,6 +12455,14 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!this.options.arkts2) { return; } + + if (TypeScriptLinter.isInForLoopBody(tsAsExpr)) { + const identifier = TypeScriptLinter.getIdentifierFromAsExpression(tsAsExpr); + if (identifier && this.isDeclaredOutsideForLoop(identifier)) { + return; + } + } + const asType = this.tsTypeChecker.getTypeAtLocation(tsAsExpr.type); const originType = this.tsTypeChecker.getTypeAtLocation(tsAsExpr.expression); const originTypeStr = this.tsTypeChecker.typeToString(originType); @@ -12465,6 +12471,34 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private isDeclaredOutsideForLoop(identifier: ts.Identifier): boolean { + const symbol = this.tsTypeChecker.getSymbolAtLocation(identifier); + if (!symbol) { + return false; + } + + const declarations = symbol.declarations ?? []; + for (const decl of declarations) { + if (ts.findAncestor(decl, ts.isForStatement)) { + return false; + } + } + + return true; + } + + private static getIdentifierFromAsExpression(asExpr: ts.AsExpression): ts.Identifier | undefined { + const expr = asExpr.expression; + if (ts.isIdentifier(expr)) { + // case: data as Type + return expr; + } else if (ts.isElementAccessExpression(expr) && ts.isIdentifier(expr.expression)) { + // case: data[i] as Type + return expr.expression; + } + return undefined; + } + private handleAssignmentNotsLikeSmartType(tsBinaryExpr: ts.BinaryExpression): void { if (!this.options.arkts2) { return; diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets b/ets2panda/linter/test/main/no_ts_like_smart_type.ets index 8a353aff28..d7b51db205 100755 --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets @@ -249,7 +249,7 @@ export class AB { return this.count_; //legal }) } -} +} class AG { h?: number; @@ -306,4 +306,62 @@ if (obj && obj.h == 3) { // valid(guarded) function check43(obj?: AG) { const val = obj.h; // NOT guarded return val; -} \ No newline at end of file +} + +} + +let NextID: number = 1; + +class downloadFilesData { + id: number; + url: string; + fileStatus: number; + downloadTime: number; + + constructor( + url: string = '', + fileStatus: number = 0, + downloadTime: number = 0, + ) { + this.id = NextID++; + this.url = url; + this.fileStatus = fileStatus; + this.downloadTime = downloadTime; + } +} + +class Downloader { + downloadFileArray: downloadFilesData[] = []; + + loadInitializationDataSource() { + let stringData = JSON.stringify([ + { + "url": "https://example.com/file1.zip", + "fileStatus": 1, + "downloadTime": 1734931200 + }, + { + "url": "https://example.com/file2.mp4", + "fileStatus": 0, + "downloadTime": 0 + }, + { + "url": "https://example.com/file3.pdf", + "fileStatus": 2, + "downloadTime": 1734931300 + } + ]); + + let data: [] = JSON.parse(stringData) as []; + + for (let i = 0; i < data.length; i++) { + const downloadItemData = data[i] as downloadFilesData; + let downloadData: downloadFilesData = new downloadFilesData( + downloadItemData.url, + downloadItemData.fileStatus, + downloadItemData.downloadTime + ); + this.downloadFileArray.push(downloadData); + } + } +} diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json old mode 100755 new mode 100644 index d5577d300c..14bb6037da --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.arkts2.json @@ -1,18 +1,4 @@ { - "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": 30, @@ -294,6 +280,36 @@ "rule": "Smart type differences (arkts-no-ts-like-smart-type)", "severity": "ERROR" }, + { + "line": 337, + "column": 27, + "endLine": 337, + "endColumn": 36, + "problem": "SdkCommonApiWhiteList", + "suggest": "", + "rule": "The \"stringify\" in SDK is no longer supported.(sdk-method-not-supported)", + "severity": "ERROR" + }, + { + "line": 337, + "column": 27, + "endLine": 337, + "endColumn": 36, + "problem": "BuiltinNarrowTypes", + "suggest": "", + "rule": "Using narrowing of types is not allowed in this API (arkts-builtin-narrow-types)", + "severity": "ERROR" + }, + { + "line": 357, + "column": 25, + "endLine": 357, + "endColumn": 36, + "problem": "NoTuplesArrays", + "suggest": "", + "rule": "Array and tuple are different type(arkts-no-tuples-arrays)", + "severity": "ERROR" + }, { "line": 137, "column": 5, diff --git a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json old mode 100755 new mode 100644 index f892c8a98b..1956437aee --- a/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json +++ b/ets2panda/linter/test/main/no_ts_like_smart_type.ets.json @@ -1,19 +1,95 @@ { - "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": 339, + "column": 9, + "endLine": 339, + "endColumn": 14, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 340, + "column": 9, + "endLine": 340, + "endColumn": 21, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 341, + "column": 9, + "endLine": 341, + "endColumn": 23, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 344, + "column": 9, + "endLine": 344, + "endColumn": 14, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 345, + "column": 9, + "endLine": 345, + "endColumn": 21, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 346, + "column": 9, + "endLine": 346, + "endColumn": 23, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 349, + "column": 9, + "endLine": 349, + "endColumn": 14, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 350, + "column": 9, + "endLine": 350, + "endColumn": 21, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, + { + "line": 351, + "column": 9, + "endLine": 351, + "endColumn": 23, + "problem": "LiteralAsPropertyName", + "suggest": "", + "rule": "Objects with property names that are not identifiers are not supported (arkts-identifiers-as-prop-names)", + "severity": "ERROR" + }, { "line": 137, "column": 5, -- Gitee From c0166ec8ec9cac068786e050a8f6485970f3c299 Mon Sep 17 00:00:00 2001 From: c30058867 Date: Sat, 23 Aug 2025 15:29:06 +0800 Subject: [PATCH 2/6] Fix the issue of missing file name checks Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICUDJF Signed-off-by: caiy --- ets2panda/linter/src/lib/TypeScriptLinter.ts | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index cd882dff73..46d0eb3cfc 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -9978,25 +9978,33 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!setApiListItem) { return; } + if (TypeScriptLinter.isInterfaceImplementation(errorNode)) { return; } + + if (ts.isTypeReferenceNode(errorNode)) { + errorNode = errorNode.typeName; + } + + const symbol = this.tsUtils.trueSymbolAtLocation(errorNode); + const oriDecl = TsUtils.getDeclaration(symbol); + const fileName = path.normalize(oriDecl?.getSourceFile().fileName || ''); const apiNamesArr = [...setApiListItem]; const hasSameApiName = apiNamesArr.some((apilistItem) => { - return apilistItem.api_info.api_name === errorNode.getText(); + return apilistItem.api_info.api_name === errorNode.getText() && + fileName.endsWith(path.normalize(apilistItem.file_path)); }); if (!hasSameApiName) { return; } - if (ts.isTypeReferenceNode(errorNode)) { - errorNode = errorNode.typeName; - } + const matchedApi = apiNamesArr.some((sdkInfo) => { const isSameName = sdkInfo.api_info.api_name === apiName; const isGlobal = sdkInfo.is_global; return isSameName && isGlobal; }); - const checkSymbol = this.isIdentifierFromSDK(errorNode); + const checkSymbol = this.isIdentifierFromSDK(symbol); const type = this.tsTypeChecker.getTypeAtLocation(errorNode); const typeName = this.tsTypeChecker.typeToString(type); @@ -10024,8 +10032,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } - private isIdentifierFromSDK(node: ts.Node): boolean { - const symbol = this.tsTypeChecker.getSymbolAtLocation(node); + private isIdentifierFromSDK(symbol: ts.Symbol | undefined): boolean { if (!symbol) { return true; } -- Gitee From 05320a961454d1a29bfad2deb2363dd18b66f216 Mon Sep 17 00:00:00 2001 From: Fouckttt Date: Fri, 22 Aug 2025 17:40:25 +0800 Subject: [PATCH 3/6] arkts-no-super-call-in-static-context Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICU4US Signed-off-by: Fouckttt --- ets2panda/linter/rule-config.json | 3 +- ets2panda/linter/src/lib/CookBookMsg.ts | 1 + ets2panda/linter/src/lib/FaultAttrs.ts | 1 + ets2panda/linter/src/lib/Problems.ts | 1 + ets2panda/linter/src/lib/TypeScriptLinter.ts | 53 ++++++++--- ...-super-call-in-static-context-negative.ets | 34 +++++++ ...l-in-static-context-negative.ets.args.json | 19 ++++ ...in-static-context-negative.ets.arkts2.json | 88 +++++++++++++++++++ ...r-call-in-static-context-negative.ets.json | 78 ++++++++++++++++ ...-super-call-in-static-context-positive.ets | 81 +++++++++++++++++ ...l-in-static-context-positive.ets.args.json | 19 ++++ ...in-static-context-positive.ets.arkts2.json | 28 ++++++ ...r-call-in-static-context-positive.ets.json | 17 ++++ 13 files changed, 410 insertions(+), 13 deletions(-) create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.args.json create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.args.json create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.json diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index 91a0529e75..cba4d0358d 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -80,7 +80,8 @@ "arkts-not-support-tuple-generic-validation", "arkts-no-optional-tuple-type", "arkts-no-large-numeric-literal", - "arkts-no-instanceof-func" + "arkts-no-instanceof-func", + "arkts-no-super-call-in-static-context" ], "interop": [ "arkts-interop-js2s-inherit-js-class", diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index b021201ab0..1d12b87e99 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -438,6 +438,7 @@ cookBookTag[408] = 'The property of IteratorResult is not supported (arkts-built cookBookTag[409] = 'No optional tuple type (arkts-no-optional-tuple-type)'; cookBookTag[410] = 'Numeric literal exceeds allowed range (arkts-no-large-numeric-literal)'; cookBookTag[411] = '"instanceof" operator can\'t be applied to function (arkts-no-instanceof-func)'; +cookBookTag[412] = 'Subclass can\'t call members of super class in static context (arkts-no-super-call-in-static-context)'; for (let i = 0; i <= cookBookTag.length; i++) { cookBookMsg[i] = ''; } diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index eedb92e745..1deaabacbe 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -309,3 +309,4 @@ faultsAttrs[FaultID.BuiltinIteratorResultValue] = new FaultAttributes(408); faultsAttrs[FaultID.OptionalTupleType] = new FaultAttributes(409); faultsAttrs[FaultID.LargeNumericLiteral] = new FaultAttributes(410); faultsAttrs[FaultID.InstanceOfFunction] = new FaultAttributes(411); +faultsAttrs[FaultID.SuperInStaticContext] = new FaultAttributes(412); diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index cfda54d13f..6e569634bc 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -298,6 +298,7 @@ export enum FaultID { OptionalTupleType, LargeNumericLiteral, InstanceOfFunction, + SuperInStaticContext, // this should always be last enum LAST_ID } diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 46d0eb3cfc..ed372db237 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -1915,6 +1915,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSdkGlobalApi(node); this.handleObjectLiteralAssignmentToClass(node); this.checkPropertyDeclarationReadonlyUsage(node); + this.handleSuperInStaticContext(node); } private checkPropertyDeclarationReadonlyUsage(propDecl: ts.PropertyDeclaration): void { @@ -2010,6 +2011,12 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } + private handleSuperInStaticContext(node: ts.PropertyDeclaration): void { + if (!!node.initializer && TsUtils.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) { + this.reportThisSuperKeywordsInStaticContext(node.initializer); + } + } + private handlePropertyAssignment(node: ts.PropertyAssignment): void { this.handleDollarBind(node); this.handlePropertyAssignmentForProp(node); @@ -2247,7 +2254,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(funcExpr, FaultID.GeneratorFunction); } if (!hasPredecessor(funcExpr, TypeScriptLinter.isClassLikeOrIface)) { - this.reportThisKeywordsInScope(funcExpr.body); + this.reportThisSuperKeywordsInStaticContext(funcExpr.body); } if (hasUnfixableReturnType) { this.incrementCounters(funcExpr, FaultID.LimitedReturnTypeInference); @@ -2258,7 +2265,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleArrowFunction(node: ts.Node): void { const arrowFunc = node as ts.ArrowFunction; if (!hasPredecessor(arrowFunc, TypeScriptLinter.isClassLikeOrIface)) { - this.reportThisKeywordsInScope(arrowFunc.body); + this.reportThisSuperKeywordsInStaticContext(arrowFunc.body); } const contextType = this.tsTypeChecker.getContextualType(arrowFunc); if (!(contextType && this.tsUtils.isLibraryType(contextType))) { @@ -2288,7 +2295,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.countDeclarationsWithDuplicateName(tsFunctionDeclaration.name, tsFunctionDeclaration); } if (tsFunctionDeclaration.body) { - this.reportThisKeywordsInScope(tsFunctionDeclaration.body); + this.reportThisSuperKeywordsInStaticContext(tsFunctionDeclaration.body); } if (this.options.arkts2) { this.handleParamType(tsFunctionDeclaration); @@ -3988,7 +3995,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleParamType(tsMethodDecl); } if (tsMethodDecl.body && isStatic) { - this.reportThisKeywordsInScope(tsMethodDecl.body); + this.reportThisSuperKeywordsInStaticContext(tsMethodDecl.body); } if (!tsMethodDecl.type) { this.handleMissingReturnType(tsMethodDecl); @@ -4762,7 +4769,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isClassDeclaration(classStaticBlockDecl.parent)) { return; } - this.reportThisKeywordsInScope(classStaticBlockDecl.body); + this.reportThisSuperKeywordsInStaticContext(classStaticBlockDecl.body); } private handleIdentifier(node: ts.Node): void { @@ -7340,19 +7347,41 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(entry.range as ts.CommentRange, FaultID.ErrorSuppression); } - private reportThisKeywordsInScope(scope: ts.Block | ts.Expression): void { - const callback = (node: ts.Node): void => { - if (node.kind === ts.SyntaxKind.ThisKeyword) { - this.incrementCounters(node, FaultID.FunctionContainsThis); - } - }; + private reportThisSuperKeywordsInStaticContext(node: ts.Block | ts.Expression): void { + if (!node.parent) { + return; + } + let callback: (node: ts.Node) => void; + if (ts.isFunctionDeclaration(node.parent)) { + callback = (node: ts.Node): void => { + if (node.kind === ts.SyntaxKind.ThisKeyword) { + this.incrementCounters(node, FaultID.FunctionContainsThis); + } + }; + } else if (ts.isPropertyDeclaration(node.parent)) { + callback = (node: ts.Node): void => { + if (node.kind === ts.SyntaxKind.SuperKeyword) { + this.incrementCounters(node, FaultID.SuperInStaticContext); + } + }; + } else { + callback = (node: ts.Node): void => { + if (node.kind === ts.SyntaxKind.ThisKeyword) { + this.incrementCounters(node, FaultID.FunctionContainsThis); + } + if (node.kind === ts.SyntaxKind.SuperKeyword) { + this.incrementCounters(node, FaultID.SuperInStaticContext); + } + }; + } + const stopCondition = (node: ts.Node): boolean => { const isClassLike = ts.isClassDeclaration(node) || ts.isClassExpression(node); const isFunctionLike = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node); const isModuleDecl = ts.isModuleDeclaration(node); return isClassLike || isFunctionLike || isModuleDecl; }; - forEachNodeInSubtree(scope, callback, stopCondition); + forEachNodeInSubtree(node, callback, stopCondition); } private handleConstructorDeclaration(node: ts.Node): void { diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets new file mode 100644 index 0000000000..9cb64f1075 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets @@ -0,0 +1,34 @@ +/* + * 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. + */ + +class A { + static foo() { + return 123; + } + static a: number = 1.0; +} + +class B extends A { + static x1: number = super.foo(); // report error for calling super class in static context. + static x2: number = super.a; // report error for calling super class in static context. + static foo() { + let x3: number = super.a; // report error for calling super class in static method. + return super.foo() + 456; // report error for calling super class in static method. + } + static { + let x4: number = super.a; // report error for calling super class in static code block. + super.foo(); // report error for calling super class in static code block. + } +} diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.args.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.args.json new file mode 100644 index 0000000000..d8d3390ad9 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.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/arkts-no-super-call-in-static-context-negative.ets.arkts2.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json new file mode 100644 index 0000000000..4755c18768 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "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": 30, + "column": 3, + "endLine": 33, + "endColumn": 4, + "problem": "NoStaticOnClass", + "suggest": "", + "rule": "Class cannot have static codeblocks. (arkts-class-lazy-import)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 23, + "endLine": 24, + "endColumn": 28, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 23, + "endLine": 25, + "endColumn": 28, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 22, + "endLine": 27, + "endColumn": 27, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 12, + "endLine": 28, + "endColumn": 17, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 22, + "endLine": 31, + "endColumn": 27, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 10, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json new file mode 100644 index 0000000000..3823d59ef6 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json @@ -0,0 +1,78 @@ +{ + "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": 24, + "column": 23, + "endLine": 24, + "endColumn": 28, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 25, + "column": 23, + "endLine": 25, + "endColumn": 28, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 27, + "column": 22, + "endLine": 27, + "endColumn": 27, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 12, + "endLine": 28, + "endColumn": 17, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 31, + "column": 22, + "endLine": 31, + "endColumn": 27, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + }, + { + "line": 32, + "column": 5, + "endLine": 32, + "endColumn": 10, + "problem": "SuperInStaticContext", + "suggest": "", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets new file mode 100644 index 0000000000..4bd51f8c1a --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets @@ -0,0 +1,81 @@ +/* + * 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. + */ + +class A { + static foo() { + return 123; + } +} + +class B extends A { + static foo() { + return A.foo() + 456; + } + static { + console.log('asd'); + A.foo(); + } +} + +class Animal1 { + name: string; + constructor(name: string) { + this.name = name; + } +} +class Dog1 extends Animal1 { + breed: string; + constructor(name: string, breed: string) { + super(name); + this.breed = breed; + } +} + +class Animal2 { + move(): void { + console.log("Moving..."); + } +} +class Dog2 extends Animal2 { + move(): void { + super.move(); + console.log("Running..."); + } +} + +class Base1 { + greet(): void { + console.log("Hello, world!"); + } +} +class Derived1 extends Base1 { + greet(): void { + super.greet(); + console.log("Hello from Derived class!"); + } +} + +class Base2 { + value: number; + constructor() { + this.value = 100; + } +} +class Derived2 extends Base2 { + constructor() { + super(); + this.value += 50; + } +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.args.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.args.json new file mode 100644 index 0000000000..d8d3390ad9 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.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/arkts-no-super-call-in-static-context-positive.ets.arkts2.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.arkts2.json new file mode 100644 index 0000000000..65e7c7a06a --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.arkts2.json @@ -0,0 +1,28 @@ +{ + "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": 26, + "column": 3, + "endLine": 29, + "endColumn": 4, + "problem": "NoStaticOnClass", + "suggest": "", + "rule": "Class cannot have static codeblocks. (arkts-class-lazy-import)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-positive.ets.json @@ -0,0 +1,17 @@ +{ + "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": [] +} \ No newline at end of file -- Gitee From 308baa04c610ea8449fe4b3fe559775e80c5941a Mon Sep 17 00:00:00 2001 From: fanglou Date: Fri, 22 Aug 2025 14:18:14 +0800 Subject: [PATCH 4/6] ArkTS1.2 not support unfixed length tuple Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICU885 Signed-off-by: fanglou --- ets2panda/linter/rule-config.json | 1 + ets2panda/linter/src/cli/CommandLineParser.ts | 6 +- ets2panda/linter/src/lib/CookBookMsg.ts | 4 +- ets2panda/linter/src/lib/FaultAttrs.ts | 1 + ets2panda/linter/src/lib/FaultDesc.ts | 1 + ets2panda/linter/src/lib/Problems.ts | 1 + ets2panda/linter/src/lib/TypeScriptLinter.ts | 12 ++- .../scan/ProblemStatisticsCommonFunction.ts | 9 +- .../utils/functions/ConfiguredRulesProcess.ts | 2 +- .../test/main/unfixed_tuple_negative.ets | 30 +++++++ .../main/unfixed_tuple_negative.ets.args.json | 19 ++++ .../unfixed_tuple_negative.ets.arkts2.json | 88 +++++++++++++++++++ .../test/main/unfixed_tuple_negative.ets.json | 17 ++++ .../test/main/unfixed_tuple_positive.ets | 36 ++++++++ .../main/unfixed_tuple_positive.ets.args.json | 19 ++++ .../unfixed_tuple_positive.ets.arkts2.json | 17 ++++ .../test/main/unfixed_tuple_positive.ets.json | 17 ++++ 17 files changed, 273 insertions(+), 7 deletions(-) create mode 100644 ets2panda/linter/test/main/unfixed_tuple_negative.ets create mode 100644 ets2panda/linter/test/main/unfixed_tuple_negative.ets.args.json create mode 100644 ets2panda/linter/test/main/unfixed_tuple_negative.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/unfixed_tuple_negative.ets.json create mode 100644 ets2panda/linter/test/main/unfixed_tuple_positive.ets create mode 100644 ets2panda/linter/test/main/unfixed_tuple_positive.ets.args.json create mode 100644 ets2panda/linter/test/main/unfixed_tuple_positive.ets.arkts2.json create mode 100644 ets2panda/linter/test/main/unfixed_tuple_positive.ets.json diff --git a/ets2panda/linter/rule-config.json b/ets2panda/linter/rule-config.json index cba4d0358d..0c613f3a2f 100644 --- a/ets2panda/linter/rule-config.json +++ b/ets2panda/linter/rule-config.json @@ -81,6 +81,7 @@ "arkts-no-optional-tuple-type", "arkts-no-large-numeric-literal", "arkts-no-instanceof-func", + "arkts-no-unfixed-len-tuple", "arkts-no-super-call-in-static-context" ], "interop": [ diff --git a/ets2panda/linter/src/cli/CommandLineParser.ts b/ets2panda/linter/src/cli/CommandLineParser.ts index 83d0e13743..e84fb2a7ad 100644 --- a/ets2panda/linter/src/cli/CommandLineParser.ts +++ b/ets2panda/linter/src/cli/CommandLineParser.ts @@ -22,7 +22,11 @@ import type { CommandLineOptions } from '../lib/CommandLineOptions'; import { cookBookTag } from '../lib/CookBookMsg'; import { Logger } from '../lib/Logger'; import { ARKTS_IGNORE_DIRS_OH_MODULES } from '../lib/utils/consts/ArktsIgnorePaths'; -import { getConfiguredRuleTags, getConfigureRulePath, getRulesFromConfig } from '../lib/utils/functions/ConfiguredRulesProcess'; +import { + getConfiguredRuleTags, + getConfigureRulePath, + getRulesFromConfig +} from '../lib/utils/functions/ConfiguredRulesProcess'; import { extractRuleTags } from '../lib/utils/functions/CookBookUtils'; import { logTscDiagnostic } from '../lib/utils/functions/LogTscDiagnostic'; diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 1d12b87e99..42299df3c9 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -438,7 +438,9 @@ cookBookTag[408] = 'The property of IteratorResult is not supported (arkts-built cookBookTag[409] = 'No optional tuple type (arkts-no-optional-tuple-type)'; cookBookTag[410] = 'Numeric literal exceeds allowed range (arkts-no-large-numeric-literal)'; cookBookTag[411] = '"instanceof" operator can\'t be applied to function (arkts-no-instanceof-func)'; -cookBookTag[412] = 'Subclass can\'t call members of super class in static context (arkts-no-super-call-in-static-context)'; +cookBookTag[412] = 'No unfixed length tuple support (arkts-no-unfixed-len-tuple)'; + +cookBookTag[413] = 'Subclass can\'t call members of super class in static context (arkts-no-super-call-in-static-context)'; for (let i = 0; i <= cookBookTag.length; i++) { cookBookMsg[i] = ''; } diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index 1deaabacbe..90c8a96668 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -309,4 +309,5 @@ faultsAttrs[FaultID.BuiltinIteratorResultValue] = new FaultAttributes(408); faultsAttrs[FaultID.OptionalTupleType] = new FaultAttributes(409); faultsAttrs[FaultID.LargeNumericLiteral] = new FaultAttributes(410); faultsAttrs[FaultID.InstanceOfFunction] = new FaultAttributes(411); +faultsAttrs[FaultID.unfixedTuple] = new FaultAttributes(412); faultsAttrs[FaultID.SuperInStaticContext] = new FaultAttributes(412); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index c57283fb1b..5b39e917f8 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -298,3 +298,4 @@ faultDesc[FaultID.BuiltinDisableApi] = 'Disable Api'; faultDesc[FaultID.BuiltinIteratorResultValue] = 'IteratorResult.value is not supported'; faultDesc[FaultID.OptionalTupleType] = 'No optional tuple type'; faultDesc[FaultID.LargeNumericLiteral] = 'Numeric literal exceeds allowed range'; +faultDesc[FaultID.unfixedTuple] = 'No unfixed tuple'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index 6e569634bc..fd32b020c0 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -298,6 +298,7 @@ export enum FaultID { OptionalTupleType, LargeNumericLiteral, InstanceOfFunction, + unfixedTuple, SuperInStaticContext, // this should always be last enum LAST_ID diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index ed372db237..20b8b1e74d 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -554,7 +554,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { [ts.SyntaxKind.AwaitExpression, this.handleAwaitExpression], [ts.SyntaxKind.PostfixUnaryExpression, this.handlePostfixUnaryExpression], [ts.SyntaxKind.BigIntLiteral, this.handleBigIntLiteral], - [ts.SyntaxKind.NumericLiteral, this.handleNumericLiteral] + [ts.SyntaxKind.NumericLiteral, this.handleNumericLiteral], + [ts.SyntaxKind.RestType, this.handleRestType] ]); lint(): void { @@ -15606,4 +15607,13 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { '"toJson" and "fromJson" (arkui-persistencev2-connect-serialization)'; this.incrementCounters(callExpr, FaultID.PersistenceV2ConnectNeedAddParam, undefined, errorMsg); } + + private handleRestType(node: ts.Node): void { + if (!this.options.arkts2) { + return; + } + if (node.parent && ts.isTupleTypeNode(node.parent)) { + this.incrementCounters(node, FaultID.unfixedTuple); + } + } } diff --git a/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts b/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts index a9c638bd7d..678929a489 100644 --- a/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts +++ b/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts @@ -165,7 +165,10 @@ export async function generateScanProbelemStatisticsReport( ); } -function getProcessedRuleToNumbersMap(ruleToNumbersMap: Map, wholeLinterRules: string[]) : Map { +function getProcessedRuleToNumbersMap( + ruleToNumbersMap: Map, + wholeLinterRules: string[] +): Map { const processedRuleToNumbersMap: Map = new Map(); const homecheckRuleToNumbersMap: Map = ruleToNumbersMap; wholeLinterRules.forEach((ruleName) => { @@ -173,10 +176,10 @@ function getProcessedRuleToNumbersMap(ruleToNumbersMap: Map, who homecheckRuleToNumbersMap.delete(ruleName); processedRuleToNumbersMap.set(ruleName, ruleNumber); }); - + homecheckRuleToNumbersMap.forEach((number, ruleName) => { processedRuleToNumbersMap.set(ruleName, number); - }) + }); return processedRuleToNumbersMap; } diff --git a/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts b/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts index 65ee056abc..6b531d29c3 100644 --- a/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts +++ b/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts @@ -97,7 +97,7 @@ function isStringArray(value: any): value is string[] { ); } -export function getwholeRules() : string[] { +export function getwholeRules(): string[] { const configureRulePath = getDefaultConfigurePath(); const configuredRulesMap = getRulesFromConfig(configureRulePath); return Array.from(configuredRulesMap.values()).flat(); diff --git a/ets2panda/linter/test/main/unfixed_tuple_negative.ets b/ets2panda/linter/test/main/unfixed_tuple_negative.ets new file mode 100644 index 0000000000..05723324d0 --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_negative.ets @@ -0,0 +1,30 @@ +/* + * 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. + */ + +const s: [string, ...boolean[]] = ['',true] // report error for unfixed tuple + +type Tuple1 = [string, ...boolean[]]; // report error for unfixed tuple + +type Tuple2 = [number, string, ...number[]]; // report error for unfixed tuple + +type Tuple3 = [...string[]]; // report error for unfixed tuple + +type Tuple4 = [...boolean[], number]; // report error for unfixed tuple + +type NestedTuple = [string, ...[number, boolean][]]; // report error for unfixed tuple + +function logTuple(args: [string, ...number[]]) { // report error for unfixed tuple + +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/unfixed_tuple_negative.ets.args.json b/ets2panda/linter/test/main/unfixed_tuple_negative.ets.args.json new file mode 100644 index 0000000000..bc4d2071da --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_negative.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": "" + } +} diff --git a/ets2panda/linter/test/main/unfixed_tuple_negative.ets.arkts2.json b/ets2panda/linter/test/main/unfixed_tuple_negative.ets.arkts2.json new file mode 100644 index 0000000000..cf32008b80 --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_negative.ets.arkts2.json @@ -0,0 +1,88 @@ +{ + "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": 19, + "endLine": 16, + "endColumn": 31, + "problem": "unfixedTuple", + "suggest": "", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 24, + "endLine": 18, + "endColumn": 36, + "problem": "unfixedTuple", + "suggest": "", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 32, + "endLine": 20, + "endColumn": 43, + "problem": "unfixedTuple", + "suggest": "", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "severity": "ERROR" + }, + { + "line": 22, + "column": 16, + "endLine": 22, + "endColumn": 27, + "problem": "unfixedTuple", + "suggest": "", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 16, + "endLine": 24, + "endColumn": 28, + "problem": "unfixedTuple", + "suggest": "", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "severity": "ERROR" + }, + { + "line": 26, + "column": 29, + "endLine": 26, + "endColumn": 51, + "problem": "unfixedTuple", + "suggest": "", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "severity": "ERROR" + }, + { + "line": 28, + "column": 34, + "endLine": 28, + "endColumn": 45, + "problem": "unfixedTuple", + "suggest": "", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "severity": "ERROR" + } + ] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/unfixed_tuple_negative.ets.json b/ets2panda/linter/test/main/unfixed_tuple_negative.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_negative.ets.json @@ -0,0 +1,17 @@ +{ + "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": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/unfixed_tuple_positive.ets b/ets2panda/linter/test/main/unfixed_tuple_positive.ets new file mode 100644 index 0000000000..e45b73893e --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_positive.ets @@ -0,0 +1,36 @@ +/* + * 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. + */ + +const s: [string, boolean[]] = ['',[true]] // ok + +const s1: [string, boolean] = ['',true] // ok + +type Tuple1 = [string, boolean[]]; // ok + +type Tuple2 = [number, string, number[]]; // ok + +type Tuple3 = [string[]]; // ok + +type Tuple4 = [boolean[], number]; // ok + +type NestedTuple = [string, [number, boolean][]]; // ok + +function logTuple(args: [string, number[]]) { // ok + +} + +function sum(...numbers: number[]): number { // ok + return numbers.reduce((total, num) => total + num, 0); +} diff --git a/ets2panda/linter/test/main/unfixed_tuple_positive.ets.args.json b/ets2panda/linter/test/main/unfixed_tuple_positive.ets.args.json new file mode 100644 index 0000000000..bc4d2071da --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_positive.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": "" + } +} diff --git a/ets2panda/linter/test/main/unfixed_tuple_positive.ets.arkts2.json b/ets2panda/linter/test/main/unfixed_tuple_positive.ets.arkts2.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_positive.ets.arkts2.json @@ -0,0 +1,17 @@ +{ + "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": [] +} \ No newline at end of file diff --git a/ets2panda/linter/test/main/unfixed_tuple_positive.ets.json b/ets2panda/linter/test/main/unfixed_tuple_positive.ets.json new file mode 100644 index 0000000000..ca88f857e9 --- /dev/null +++ b/ets2panda/linter/test/main/unfixed_tuple_positive.ets.json @@ -0,0 +1,17 @@ +{ + "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": [] +} \ No newline at end of file -- Gitee From c49b93a1cd1a25f4011f89f39741cb213472157b Mon Sep 17 00:00:00 2001 From: HuSenlin Date: Mon, 25 Aug 2025 11:13:58 +0800 Subject: [PATCH 5/6] fix AI reaview Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICUHSK Signed-off-by: HuSenlin --- ets2panda/linter/src/cli/LinterCLI.ts | 4 +- ets2panda/linter/src/lib/TypeScriptLinter.ts | 6 +- .../scan/ProblemStatisticsCommonFunction.ts | 10 +- .../scan/StatisticsReportInPutInfo.ts | 2 +- ets2panda/linter/src/lib/utils/TsUtils.ts | 2 +- .../utils/functions/ConfiguredRulesProcess.ts | 2 +- .../deprecatedapi/common_api.ets.arkts2.json | 50 ------- .../dragController.ets.arkts2.json | 10 -- .../deprecatedapi/progress.ets.arkts2.json | 20 --- ...in-static-context-negative.ets.arkts2.json | 12 +- ...r-call-in-static-context-negative.ets.json | 12 +- .../styles_decorator_struct_1.ets.arkts2.json | 10 -- ...styles_decorator_struct_1.ets.autofix.json | 10 -- ...styles_decorator_struct_1.ets.migrate.json | 10 -- .../styles_decorator_struct_2.ets.arkts2.json | 10 -- ...styles_decorator_struct_2.ets.autofix.json | 10 -- ...styles_decorator_struct_2.ets.migrate.json | 10 -- ...cl_with_duplicate_name_sdk.ets.arkts2.json | 130 ------------------ 18 files changed, 25 insertions(+), 295 deletions(-) diff --git a/ets2panda/linter/src/cli/LinterCLI.ts b/ets2panda/linter/src/cli/LinterCLI.ts index 9d8ae8337f..be7e4cdaaa 100644 --- a/ets2panda/linter/src/cli/LinterCLI.ts +++ b/ets2panda/linter/src/cli/LinterCLI.ts @@ -32,7 +32,7 @@ import { logStatistics } from '../lib/statistics/StatisticsLogger'; import { compileLintOptions, getEtsLoaderPath } from '../lib/ts-compiler/Compiler'; import { processSyncErr, processSyncOut } from '../lib/utils/functions/ProcessWrite'; import { parseCommandLine } from './CommandLineParser'; -import { getwholeRules } from '../lib/utils/functions/ConfiguredRulesProcess'; +import { getAllLinterRules } from '../lib/utils/functions/ConfiguredRulesProcess'; export function run(): void { const commandLineArgs = process.argv.slice(2); @@ -78,7 +78,7 @@ async function runIdeInteractiveMode(cmdOptions: CommandLineOptions): Promise { const isSameName = sdkInfo.api_info.api_name === apiName; const isGlobal = sdkInfo.is_global; return isSameName && isGlobal; }); - const checkSymbol = this.isIdentifierFromSDK(symbol); + const checkSymbol = TypeScriptLinter.isIdentifierFromSDK(symbol); const type = this.tsTypeChecker.getTypeAtLocation(errorNode); const typeName = this.tsTypeChecker.typeToString(type); @@ -10062,7 +10062,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } - private isIdentifierFromSDK(symbol: ts.Symbol | undefined): boolean { + static isIdentifierFromSDK(symbol: ts.Symbol | undefined): boolean { if (!symbol) { return true; } diff --git a/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts b/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts index 678929a489..e8e8f93510 100644 --- a/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts +++ b/ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts @@ -27,7 +27,7 @@ import type { RuleDetailedErrorInfo } from './RuleDetailedErrorInfo'; import type { StatisticsReportInPutInfo } from './StatisticsReportInPutInfo'; import type { TimeRecorder } from './TimeRecorder'; import { WorkLoadInfo } from './WorkLoadInfo'; -import { getwholeRules } from '../../utils/functions/ConfiguredRulesProcess'; +import { getAllLinterRules } from '../../utils/functions/ConfiguredRulesProcess'; export function getProblemStatisticsInfo( problemNumbers: ProblemNumbersInfo, @@ -153,7 +153,7 @@ export async function generateScanProbelemStatisticsReport( workLoadInfo.calculateFixRate(problemNumbers); const statisticsReportData = getProblemStatisticsInfo( problemNumbers, - getProcessedRuleToNumbersMap(statisticsReportInPutInfo.ruleToNumbersMap, statisticsReportInPutInfo.wholeRules), + getProcessedRuleToNumbersMap(statisticsReportInPutInfo.ruleToNumbersMap, statisticsReportInPutInfo.allLinterRules), statisticsReportInPutInfo.ruleToAutoFixedNumbersMap, statisticsReportInPutInfo.timeRecorder, workLoadInfo @@ -167,11 +167,11 @@ export async function generateScanProbelemStatisticsReport( function getProcessedRuleToNumbersMap( ruleToNumbersMap: Map, - wholeLinterRules: string[] + allLinterRules: string[] ): Map { const processedRuleToNumbersMap: Map = new Map(); const homecheckRuleToNumbersMap: Map = ruleToNumbersMap; - wholeLinterRules.forEach((ruleName) => { + allLinterRules.forEach((ruleName) => { const ruleNumber = ruleToNumbersMap.get(ruleName) || 0; homecheckRuleToNumbersMap.delete(ruleName); processedRuleToNumbersMap.set(ruleName, ruleNumber); @@ -216,7 +216,7 @@ export function generateMigrationStatisicsReport( const statisticsReportData = getProblemStatisticsInfo( problemNumbers, - getProcessedRuleToNumbersMap(ruleToNumbersMap, getwholeRules()), + getProcessedRuleToNumbersMap(ruleToNumbersMap, getAllLinterRules()), ruleToAutoFixedNumbersMap, timeRecorder ); diff --git a/ets2panda/linter/src/lib/statistics/scan/StatisticsReportInPutInfo.ts b/ets2panda/linter/src/lib/statistics/scan/StatisticsReportInPutInfo.ts index b43198f2fe..a841890f97 100644 --- a/ets2panda/linter/src/lib/statistics/scan/StatisticsReportInPutInfo.ts +++ b/ets2panda/linter/src/lib/statistics/scan/StatisticsReportInPutInfo.ts @@ -20,7 +20,7 @@ export class StatisticsReportInPutInfo { totalProblemNumbers: number = 0; arkOnePointOneProblemNumbers: number = 0; ruleToNumbersMap: Map = {} as Map; - wholeRules: string[] = [] as string[]; + allLinterRules: string[] = [] as string[]; ruleToAutoFixedNumbersMap: Map = {} as Map; cmdOptions: CommandLineOptions = {} as CommandLineOptions; timeRecorder: TimeRecorder = {} as TimeRecorder; diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index d49c2cdff9..3aa1893629 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -3590,7 +3590,7 @@ export class TsUtils { return false; } - projectPath.concat(PATH_SEPARATOR + currentModule); + projectPath = projectPath.concat(PATH_SEPARATOR + currentModule); } const importedFile = path.resolve(projectPath, importFilePath + extension); diff --git a/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts b/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts index 6b531d29c3..27bf5988bd 100644 --- a/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts +++ b/ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts @@ -97,7 +97,7 @@ function isStringArray(value: any): value is string[] { ); } -export function getwholeRules(): string[] { +export function getAllLinterRules(): string[] { const configureRulePath = getDefaultConfigurePath(); const configuredRulesMap = getRulesFromConfig(configureRulePath); return Array.from(configuredRulesMap.values()).flat(); diff --git a/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json index 477f1080b2..d74d9c0a2c 100644 --- a/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/common_api.ets.arkts2.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 19, - "column": 23, - "endLine": 19, - "endColumn": 32, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 20, "column": 22, @@ -164,16 +154,6 @@ "rule": "The ArkUI interface \"TransitionOptions\" is deprecated (arkui-deprecated-interface)", "severity": "ERROR" }, - { - "line": 47, - "column": 17, - "endLine": 47, - "endColumn": 26, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 50, "column": 36, @@ -264,16 +244,6 @@ "rule": "The ArkUI interface \"LayoutChild\" is deprecated (arkui-deprecated-interface)", "severity": "ERROR" }, - { - "line": 96, - "column": 31, - "endLine": 96, - "endColumn": 40, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 97, "column": 26, @@ -294,16 +264,6 @@ "rule": "The ArkUI interface \"getY\" is deprecated (arkui-deprecated-interface)", "severity": "ERROR" }, - { - "line": 98, - "column": 23, - "endLine": 98, - "endColumn": 32, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 99, "column": 34, @@ -324,16 +284,6 @@ "rule": "The ArkUI interface \"getY\" is deprecated (arkui-deprecated-interface)", "severity": "ERROR" }, - { - "line": 109, - "column": 26, - "endLine": 109, - "endColumn": 35, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 111, "column": 28, diff --git a/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json index 1e77318c1c..f6115f9b14 100644 --- a/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/dragController.ets.arkts2.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 48, - "column": 33, - "endLine": 48, - "endColumn": 46, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 67, "column": 27, diff --git a/ets2panda/linter/test/deprecatedapi/progress.ets.arkts2.json b/ets2panda/linter/test/deprecatedapi/progress.ets.arkts2.json index efa1d99076..9f2cb2ef50 100755 --- a/ets2panda/linter/test/deprecatedapi/progress.ets.arkts2.json +++ b/ets2panda/linter/test/deprecatedapi/progress.ets.arkts2.json @@ -14,26 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 19, - "column": 26, - "endLine": 19, - "endColumn": 40, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 19, - "column": 47, - "endLine": 19, - "endColumn": 61, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 19, "column": 47, diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json index 4755c18768..ca714a4708 100644 --- a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json @@ -31,7 +31,7 @@ "endColumn": 28, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -41,7 +41,7 @@ "endColumn": 28, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 27, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 17, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 27, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 10, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json index 3823d59ef6..e54aa0b6c4 100644 --- a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json @@ -21,7 +21,7 @@ "endColumn": 28, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -31,7 +31,7 @@ "endColumn": 28, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -41,7 +41,7 @@ "endColumn": 27, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 17, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 27, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 10, "problem": "SuperInStaticContext", "suggest": "", - "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", + "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json index a0db527450..50f72ada9e 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.arkts2.json @@ -54,16 +54,6 @@ "rule": "\"@Styles\" decorator is not supported (arkui-no-styles-decorator)", "severity": "ERROR" }, - { - "line": 103, - "column": 24, - "endLine": 103, - "endColumn": 37, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 105, "column": 3, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json index 0d3f2bf7cf..67362091ff 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.autofix.json @@ -134,16 +134,6 @@ "rule": "\"@Styles\" decorator is not supported (arkui-no-styles-decorator)", "severity": "ERROR" }, - { - "line": 103, - "column": 24, - "endLine": 103, - "endColumn": 37, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 105, "column": 3, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json index a860c9a7c7..309824bb24 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_1.ets.migrate.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 116, - "column": 24, - "endLine": 116, - "endColumn": 37, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 120, "column": 26, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json index 4eb3f7e164..4e818a87e4 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.arkts2.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 103, - "column": 24, - "endLine": 103, - "endColumn": 37, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 107, "column": 26, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json index 4eb3f7e164..4e818a87e4 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.autofix.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 103, - "column": 24, - "endLine": 103, - "endColumn": 37, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 107, "column": 26, diff --git a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json index 4eb3f7e164..4e818a87e4 100644 --- a/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json +++ b/ets2panda/linter/test/main/styles_decorator_struct_2.ets.migrate.json @@ -14,16 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 103, - "column": 24, - "endLine": 103, - "endColumn": 37, - "problem": "LimitedVoidTypeFromSdk", - "suggest": "", - "rule": "Type \"void\" has no instances.(sdk-limited-void-type)", - "severity": "ERROR" - }, { "line": 107, "column": 26, diff --git a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json index 250fb9600a..b41be47d2a 100644 --- a/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json +++ b/ets2panda/linter/test/sdkwhite/decl_with_duplicate_name_sdk.ets.arkts2.json @@ -14,26 +14,6 @@ "limitations under the License." ], "result": [ - { - "line": 20, - "column": 19, - "endLine": 20, - "endColumn": 28, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 35, - "endLine": 20, - "endColumn": 44, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 20, "column": 35, @@ -44,26 +24,6 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, - { - "line": 21, - "column": 19, - "endLine": 21, - "endColumn": 28, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 27, - "endLine": 22, - "endColumn": 36, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 22, "column": 44, @@ -84,16 +44,6 @@ "rule": "Type inference in case of generic function calls is limited (arkts-no-inferred-generic-params)", "severity": "ERROR" }, - { - "line": 25, - "column": 31, - "endLine": 25, - "endColumn": 40, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 25, "column": 31, @@ -104,76 +54,6 @@ "rule": "\"new\" expression with dynamic constructor type is not supported (arkts-no-dynamic-ctor-call)", "severity": "ERROR" }, - { - "line": 30, - "column": 38, - "endLine": 30, - "endColumn": 47, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 40, - "column": 30, - "endLine": 40, - "endColumn": 39, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 46, - "column": 42, - "endLine": 46, - "endColumn": 60, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 47, - "column": 42, - "endLine": 47, - "endColumn": 60, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 49, - "column": 31, - "endLine": 49, - "endColumn": 49, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 50, - "column": 31, - "endLine": 50, - "endColumn": 49, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, - { - "line": 53, - "column": 18, - "endLine": 53, - "endColumn": 36, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 54, "column": 15, @@ -194,16 +74,6 @@ "rule": "Use explicit types instead of \"any\", \"unknown\" (arkts-no-any-unknown)", "severity": "ERROR" }, - { - "line": 54, - "column": 19, - "endLine": 54, - "endColumn": 37, - "problem": "DuplicateDeclNameFromSdk", - "suggest": "", - "rule": "API path have changed - please update your imports accordingly (sdk-no-decl-with-duplicate-name)", - "severity": "ERROR" - }, { "line": 67, "column": 3, -- Gitee From d59dd02e51d9687f7d0064a8c57a864f711c2a67 Mon Sep 17 00:00:00 2001 From: Fouckttt Date: Fri, 22 Aug 2025 17:40:25 +0800 Subject: [PATCH 6/6] arkts-no-super-call-in-static-context Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICU4US Signed-off-by: Fouckttt fix comment Issue:https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICU4US Signed-off-by: Fouckttt --- ets2panda/linter/src/lib/FaultAttrs.ts | 2 +- ets2panda/linter/src/lib/TypeScriptLinter.ts | 78 ++++++++----------- ...in-static-context-negative.ets.arkts2.json | 12 +-- ...r-call-in-static-context-negative.ets.json | 63 +-------------- 4 files changed, 42 insertions(+), 113 deletions(-) diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index 90c8a96668..7de7999b99 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -310,4 +310,4 @@ faultsAttrs[FaultID.OptionalTupleType] = new FaultAttributes(409); faultsAttrs[FaultID.LargeNumericLiteral] = new FaultAttributes(410); faultsAttrs[FaultID.InstanceOfFunction] = new FaultAttributes(411); faultsAttrs[FaultID.unfixedTuple] = new FaultAttributes(412); -faultsAttrs[FaultID.SuperInStaticContext] = new FaultAttributes(412); +faultsAttrs[FaultID.SuperInStaticContext] = new FaultAttributes(413); diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index f58d96ee13..15cb57df97 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -555,7 +555,8 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { [ts.SyntaxKind.PostfixUnaryExpression, this.handlePostfixUnaryExpression], [ts.SyntaxKind.BigIntLiteral, this.handleBigIntLiteral], [ts.SyntaxKind.NumericLiteral, this.handleNumericLiteral], - [ts.SyntaxKind.RestType, this.handleRestType] + [ts.SyntaxKind.RestType, this.handleRestType], + [ts.SyntaxKind.SuperKeyword, this.handleSuperKeyword] ]); lint(): void { @@ -1916,7 +1917,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleSdkGlobalApi(node); this.handleObjectLiteralAssignmentToClass(node); this.checkPropertyDeclarationReadonlyUsage(node); - this.handleSuperInStaticContext(node); } private checkPropertyDeclarationReadonlyUsage(propDecl: ts.PropertyDeclaration): void { @@ -2012,12 +2012,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } } - private handleSuperInStaticContext(node: ts.PropertyDeclaration): void { - if (!!node.initializer && TsUtils.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) { - this.reportThisSuperKeywordsInStaticContext(node.initializer); - } - } - private handlePropertyAssignment(node: ts.PropertyAssignment): void { this.handleDollarBind(node); this.handlePropertyAssignmentForProp(node); @@ -2255,7 +2249,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(funcExpr, FaultID.GeneratorFunction); } if (!hasPredecessor(funcExpr, TypeScriptLinter.isClassLikeOrIface)) { - this.reportThisSuperKeywordsInStaticContext(funcExpr.body); + this.reportThisKeywordsInScope(funcExpr.body); } if (hasUnfixableReturnType) { this.incrementCounters(funcExpr, FaultID.LimitedReturnTypeInference); @@ -2266,7 +2260,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { private handleArrowFunction(node: ts.Node): void { const arrowFunc = node as ts.ArrowFunction; if (!hasPredecessor(arrowFunc, TypeScriptLinter.isClassLikeOrIface)) { - this.reportThisSuperKeywordsInStaticContext(arrowFunc.body); + this.reportThisKeywordsInScope(arrowFunc.body); } const contextType = this.tsTypeChecker.getContextualType(arrowFunc); if (!(contextType && this.tsUtils.isLibraryType(contextType))) { @@ -2296,7 +2290,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.countDeclarationsWithDuplicateName(tsFunctionDeclaration.name, tsFunctionDeclaration); } if (tsFunctionDeclaration.body) { - this.reportThisSuperKeywordsInStaticContext(tsFunctionDeclaration.body); + this.reportThisKeywordsInScope(tsFunctionDeclaration.body); } if (this.options.arkts2) { this.handleParamType(tsFunctionDeclaration); @@ -3996,7 +3990,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.handleParamType(tsMethodDecl); } if (tsMethodDecl.body && isStatic) { - this.reportThisSuperKeywordsInStaticContext(tsMethodDecl.body); + this.reportThisKeywordsInScope(tsMethodDecl.body); } if (!tsMethodDecl.type) { this.handleMissingReturnType(tsMethodDecl); @@ -4770,7 +4764,7 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { if (!ts.isClassDeclaration(classStaticBlockDecl.parent)) { return; } - this.reportThisSuperKeywordsInStaticContext(classStaticBlockDecl.body); + this.reportThisKeywordsInScope(classStaticBlockDecl.body); } private handleIdentifier(node: ts.Node): void { @@ -7348,41 +7342,19 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(entry.range as ts.CommentRange, FaultID.ErrorSuppression); } - private reportThisSuperKeywordsInStaticContext(node: ts.Block | ts.Expression): void { - if (!node.parent) { - return; - } - let callback: (node: ts.Node) => void; - if (ts.isFunctionDeclaration(node.parent)) { - callback = (node: ts.Node): void => { - if (node.kind === ts.SyntaxKind.ThisKeyword) { - this.incrementCounters(node, FaultID.FunctionContainsThis); - } - }; - } else if (ts.isPropertyDeclaration(node.parent)) { - callback = (node: ts.Node): void => { - if (node.kind === ts.SyntaxKind.SuperKeyword) { - this.incrementCounters(node, FaultID.SuperInStaticContext); - } - }; - } else { - callback = (node: ts.Node): void => { - if (node.kind === ts.SyntaxKind.ThisKeyword) { - this.incrementCounters(node, FaultID.FunctionContainsThis); - } - if (node.kind === ts.SyntaxKind.SuperKeyword) { - this.incrementCounters(node, FaultID.SuperInStaticContext); - } - }; - } - + private reportThisKeywordsInScope(scope: ts.Block | ts.Expression): void { + const callback = (node: ts.Node): void => { + if (node.kind === ts.SyntaxKind.ThisKeyword) { + this.incrementCounters(node, FaultID.FunctionContainsThis); + } + }; const stopCondition = (node: ts.Node): boolean => { const isClassLike = ts.isClassDeclaration(node) || ts.isClassExpression(node); const isFunctionLike = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node); const isModuleDecl = ts.isModuleDeclaration(node); return isClassLike || isFunctionLike || isModuleDecl; }; - forEachNodeInSubtree(node, callback, stopCondition); + forEachNodeInSubtree(scope, callback, stopCondition); } private handleConstructorDeclaration(node: ts.Node): void { @@ -10022,8 +9994,10 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { const fileName = path.normalize(oriDecl?.getSourceFile().fileName || ''); const apiNamesArr = [...setApiListItem]; const hasSameApiName = apiNamesArr.some((apilistItem) => { - return apilistItem.api_info.api_name === errorNode.getText() && - fileName.endsWith(path.normalize(apilistItem.file_path)); + return ( + apilistItem.api_info.api_name === errorNode.getText() && + fileName.endsWith(path.normalize(apilistItem.file_path)) + ); }); if (!hasSameApiName) { return; @@ -15616,4 +15590,20 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { this.incrementCounters(node, FaultID.unfixedTuple); } } + + private handleSuperKeyword(node: ts.Node): void { + if (!this.options.arkts2) { + return; + } + const staticContext = ts.findAncestor(node, (parent) => { + return ( + parent && + (ts.canHaveModifiers(parent) && TsUtils.hasModifier(parent.modifiers, ts.SyntaxKind.StaticKeyword) || + ts.isClassStaticBlockDeclaration(parent)) + ); + }); + if (staticContext) { + this.incrementCounters(node, FaultID.SuperInStaticContext); + } + } } diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json index ca714a4708..4755c18768 100644 --- a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.arkts2.json @@ -31,7 +31,7 @@ "endColumn": 28, "problem": "SuperInStaticContext", "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", "severity": "ERROR" }, { @@ -41,7 +41,7 @@ "endColumn": 28, "problem": "SuperInStaticContext", "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", "severity": "ERROR" }, { @@ -51,7 +51,7 @@ "endColumn": 27, "problem": "SuperInStaticContext", "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", "severity": "ERROR" }, { @@ -61,7 +61,7 @@ "endColumn": 17, "problem": "SuperInStaticContext", "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", "severity": "ERROR" }, { @@ -71,7 +71,7 @@ "endColumn": 27, "problem": "SuperInStaticContext", "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", "severity": "ERROR" }, { @@ -81,7 +81,7 @@ "endColumn": 10, "problem": "SuperInStaticContext", "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", + "rule": "Subclass can't call members of super class in static context (arkts-no-super-call-in-static-context)", "severity": "ERROR" } ] diff --git a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json index e54aa0b6c4..ca88f857e9 100644 --- a/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json +++ b/ets2panda/linter/test/main/arkts-no-super-call-in-static-context-negative.ets.json @@ -13,66 +13,5 @@ "See the License for the specific language governing permissions and", "limitations under the License." ], - "result": [ - { - "line": 24, - "column": 23, - "endLine": 24, - "endColumn": 28, - "problem": "SuperInStaticContext", - "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", - "severity": "ERROR" - }, - { - "line": 25, - "column": 23, - "endLine": 25, - "endColumn": 28, - "problem": "SuperInStaticContext", - "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", - "severity": "ERROR" - }, - { - "line": 27, - "column": 22, - "endLine": 27, - "endColumn": 27, - "problem": "SuperInStaticContext", - "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 12, - "endLine": 28, - "endColumn": 17, - "problem": "SuperInStaticContext", - "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", - "severity": "ERROR" - }, - { - "line": 31, - "column": 22, - "endLine": 31, - "endColumn": 27, - "problem": "SuperInStaticContext", - "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", - "severity": "ERROR" - }, - { - "line": 32, - "column": 5, - "endLine": 32, - "endColumn": 10, - "problem": "SuperInStaticContext", - "suggest": "", - "rule": "No unfixed length tuple support (arkts-no-unfixed-len-tuple)", - "severity": "ERROR" - } - ] + "result": [] } \ No newline at end of file -- Gitee