From e1858704f849ad1565266be9014be9c6295b263b Mon Sep 17 00:00:00 2001 From: sefayilmazunal Date: Thu, 19 Jun 2025 14:43:22 +0300 Subject: [PATCH] reverted arkts interop-d2s-export-entity rule Description: arkts interop-d2s-export-entity rule and affected code deleted Issue: #ICGGA4 Signed-off-by: sefayilmazunal --- ets2panda/linter/src/lib/CookBookMsg.ts | 1 - 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 | 31 ---- ets2panda/linter/src/lib/utils/TsUtils.ts | 35 ----- .../src/lib/utils/consts/ArkTS2Rules.ts | 1 - .../test/interop/interop_export_js_rules.ets | 4 - .../interop_export_js_rules.ets.arkts2.json | 144 +++++++----------- 9 files changed, 57 insertions(+), 162 deletions(-) diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 17c0d8899b..2bdb84a2f5 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -315,7 +315,6 @@ cookBookTag[319] = cookBookTag[321] = 'Import Concurrency is not required (arkts-limited-stdlib-no-import-concurrency)'; cookBookTag[322] = 'isConcurrent is not supported (arkts-limited-stdlib-no-support-isConcurrent)'; cookBookTag[323] = 'Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)'; -cookBookTag[324] = 'Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)'; cookBookTag[325] = 'Default parameters must be placed after mandatory parameters (arkts-default-args-behind-required-args)'; cookBookTag[326] = 'It is not allowed to create object literal in interop calls (arkts-interop-s2d-object-literal)'; diff --git a/ets2panda/linter/src/lib/FaultAttrs.ts b/ets2panda/linter/src/lib/FaultAttrs.ts index 07f5587812..cb4c365633 100644 --- a/ets2panda/linter/src/lib/FaultAttrs.ts +++ b/ets2panda/linter/src/lib/FaultAttrs.ts @@ -222,7 +222,6 @@ faultsAttrs[FaultID.MethodInheritRule] = new FaultAttributes(319); faultsAttrs[FaultID.LimitedStdLibNoImportConcurrency] = new FaultAttributes(321); faultsAttrs[FaultID.IsConcurrentDeprecated] = new FaultAttributes(322); faultsAttrs[FaultID.InteropJsObjectExport] = new FaultAttributes(323); -faultsAttrs[FaultID.InteropArkTs1ObjectExport] = new FaultAttributes(324); faultsAttrs[FaultID.DefaultArgsBehindRequiredArgs] = new FaultAttributes(325); faultsAttrs[FaultID.InteropStaticObjectLiterals] = new FaultAttributes(326); faultsAttrs[FaultID.InteropObjectLiteralAmbiguity] = new FaultAttributes(327); diff --git a/ets2panda/linter/src/lib/FaultDesc.ts b/ets2panda/linter/src/lib/FaultDesc.ts index 49646a1965..12537c0874 100644 --- a/ets2panda/linter/src/lib/FaultDesc.ts +++ b/ets2panda/linter/src/lib/FaultDesc.ts @@ -173,7 +173,6 @@ faultDesc[FaultID.ExtendsExpression] = 'Extends Expression'; faultDesc[FaultID.NumericSemantics] = 'Numeric semantics'; faultDesc[FaultID.AnimatableExtendDecoratorTransform] = '"@AnimatableExtend" decorator'; faultDesc[FaultID.InteropJsObjectExport] = 'Interop JS object export'; -faultDesc[FaultID.InteropArkTs1ObjectExport] = 'Interop ArkTS1.0 object export'; faultDesc[FaultID.DefaultArgsBehindRequiredArgs] = 'Default parameters before mandatory'; faultDesc[FaultID.NoDuplicateFunctionName] = 'No duplicate function name'; faultDesc[FaultID.OhmUrlFullPath] = 'Require full path file name'; diff --git a/ets2panda/linter/src/lib/Problems.ts b/ets2panda/linter/src/lib/Problems.ts index e9dd80975f..38918fe21c 100644 --- a/ets2panda/linter/src/lib/Problems.ts +++ b/ets2panda/linter/src/lib/Problems.ts @@ -202,7 +202,6 @@ export enum FaultID { InteropJsObjectTraverseJsInstance, InteropJsObjectCallStaticFunc, InteropJsObjectExport, - InteropArkTs1ObjectExport, DefaultArgsBehindRequiredArgs, LimitedStdLibNoImportConcurrency, MissingSuperCall, diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 99cce1c984..61bf39dbdd 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -4718,32 +4718,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return false; } - private isExportedEntityDeclaredInArkTs1(exportDecl: ts.ExportDeclaration): boolean | undefined { - if (!this.options.arkts2 || !this.useStatic) { - return false; - } - - // For named exports with braces { ... } - if (exportDecl.exportClause && ts.isNamedExports(exportDecl.exportClause)) { - for (const exportSpecifier of exportDecl.exportClause.elements) { - const identifier = exportSpecifier.name; - if (this.tsUtils.isExportImportedFromArkTs1(identifier, exportDecl)) { - return true; - } - } - } - - // For namespace exports (export * as namespace from ...) - if (exportDecl.exportClause && ts.isNamespaceExport(exportDecl.exportClause)) { - const namespaceIdentifier = exportDecl.exportClause.name; - if (this.tsUtils.isExportImportedFromArkTs1(namespaceIdentifier, exportDecl)) { - return true; - } - } - - return false; - } - private isDeclaredInArkTs2(callSignature: ts.Signature): boolean | undefined { const declarationSourceFile = callSignature?.declaration?.getSourceFile(); if (!declarationSourceFile) { @@ -6069,11 +6043,6 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { return; } - if (this.isExportedEntityDeclaredInArkTs1(exportDecl)) { - this.incrementCounters(node, FaultID.InteropArkTs1ObjectExport); - return; - } - if (!TypeScriptLinter.inSharedModule(node) || ts.isModuleBlock(node.parent)) { return; } diff --git a/ets2panda/linter/src/lib/utils/TsUtils.ts b/ets2panda/linter/src/lib/utils/TsUtils.ts index 7aa8050e88..31cb57ebd8 100644 --- a/ets2panda/linter/src/lib/utils/TsUtils.ts +++ b/ets2panda/linter/src/lib/utils/TsUtils.ts @@ -3701,41 +3701,6 @@ export class TsUtils { return undefined; } - /** - * Checks whether an exported identifier is imported from an ArkTS1 file. - * @param exportIdentifier The exported identifier to check. - * @param node The node where the export occurs (used to get the current source file). - * @returns true if imported from ArkTS1, false if not, undefined if undetermined. - */ - isExportImportedFromArkTs1(exportIdentifier: ts.Identifier, node: ts.Node): boolean | undefined { - // Get the symbol associated with the identifier. - const symbol = this.tsTypeChecker.getSymbolAtLocation(exportIdentifier); - if (!symbol) { - return undefined; - } - - // If the symbol is an alias (imported), resolve the real symbol. - const realSymbol = - (symbol.flags & ts.SymbolFlags.Alias) !== 0 ? this.tsTypeChecker.getAliasedSymbol(symbol) : undefined; - - const declarations = realSymbol?.getDeclarations(); - if (!declarations || declarations.length === 0) { - return undefined; - } - - // Get the source file where the declaration is located. - const importSourceFile = declarations[0].getSourceFile(); - - // Ensure import is from ArkTS1 file and usage is in ArkTS1.2 file - const currentSourceFile = node.getSourceFile(); - return ( - importSourceFile.fileName.endsWith(EXTNAME_ETS) && - currentSourceFile.fileName.endsWith(EXTNAME_ETS) && - !this.isArkts12File(importSourceFile) && - this.isArkts12File(currentSourceFile) - ); - } - isArkts12File(sourceFile: ts.SourceFile): boolean { if (!sourceFile?.fileName) { return false; diff --git a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts index 2eaef243aa..62c689b5a5 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts @@ -107,7 +107,6 @@ export const arkts2Rules: number[] = [ 321, 322, 323, - 324, 325, 326, 327, diff --git a/ets2panda/linter/test/interop/interop_export_js_rules.ets b/ets2panda/linter/test/interop/interop_export_js_rules.ets index e729a7c2c3..3ab29fe81d 100644 --- a/ets2panda/linter/test/interop/interop_export_js_rules.ets +++ b/ets2panda/linter/test/interop/interop_export_js_rules.ets @@ -19,10 +19,6 @@ export {ff1} // imported from js. Error is shown export { ff2 } from "./interop_import_js_rules_js" // ff2 is imported from js. Error is shown -export { MyDecorator } from "./oh_modules/ets_decorator" // MyDecorator is imported from arkts1. Error is shown - export { foo as bar } from "./oh_modules/reflect_export" // foo is imported from arkts1.2. No error. -export * as namespace1 from "./oh_modules/ets_decorator" - export * as namespace2 from "./interop_import_js_rules_js" diff --git a/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json b/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json index 1f92c538cd..827762e0bf 100644 --- a/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json +++ b/ets2panda/linter/test/interop/interop_export_js_rules.ets.arkts2.json @@ -1,88 +1,58 @@ { - "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": 1, - "endLine": 16, - "endColumn": 51, - "problem": "InterOpImportJs", - "suggest": "", - "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", - "severity": "ERROR" - }, - { - "line": 18, - "column": 1, - "endLine": 18, - "endColumn": 13, - "problem": "InteropJsObjectExport", - "suggest": "", - "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", - "severity": "ERROR" - }, - { - "line": 20, - "column": 1, - "endLine": 20, - "endColumn": 51, - "problem": "InteropJsObjectExport", - "suggest": "", - "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", - "severity": "ERROR" - }, - { - "line": 22, - "column": 1, - "endLine": 22, - "endColumn": 57, - "problem": "InteropArkTs1ObjectExport", - "suggest": "", - "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", - "severity": "ERROR" - }, - { - "line": 24, - "column": 1, - "endLine": 24, - "endColumn": 57, - "problem": "InteropArkTs1ObjectExport", - "suggest": "", - "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", - "severity": "ERROR" - }, - { - "line": 26, - "column": 1, - "endLine": 26, - "endColumn": 57, - "problem": "InteropArkTs1ObjectExport", - "suggest": "", - "rule": "Direct export of interop ArkTS1.0 objects is not supported (arkts-interop-d2s-export-entity)", - "severity": "ERROR" - }, - { - "line": 28, - "column": 1, - "endLine": 28, - "endColumn": 59, - "problem": "InteropJsObjectExport", - "suggest": "", - "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", - "severity": "ERROR" - } - ] -} \ No newline at end of file + "copyright": [ + "Copyright (c) 2025 Huawei Device Co., Ltd.", + "Licensed under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License.", + "You may obtain a copy of the License at", + "", + "http://www.apache.org/licenses/LICENSE-2.0", + "", + "Unless required by applicable law or agreed to in writing, software", + "distributed under the License is distributed on an 'AS IS' BASIS,", + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.", + "See the License for the specific language governing permissions and", + "limitations under the License." + ], + "result": [ + { + "line": 16, + "column": 1, + "endLine": 16, + "endColumn": 51, + "problem": "InterOpImportJs", + "suggest": "", + "rule": "Importing directly from \"JS\" module is not supported (arkts-interop-js2s-import-js)", + "severity": "ERROR" + }, + { + "line": 18, + "column": 1, + "endLine": 18, + "endColumn": 13, + "problem": "InteropJsObjectExport", + "suggest": "", + "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", + "severity": "ERROR" + }, + { + "line": 20, + "column": 1, + "endLine": 20, + "endColumn": 51, + "problem": "InteropJsObjectExport", + "suggest": "", + "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", + "severity": "ERROR" + }, + { + "line": 24, + "column": 1, + "endLine": 24, + "endColumn": 59, + "problem": "InteropJsObjectExport", + "suggest": "", + "rule": "Direct export of interop JS objects is not supported (arkts-interop-js2s-export-js)", + "severity": "ERROR" + } + ] +} -- Gitee