From d651539171a62c570c9d7183d5a71b0b7f596a80 Mon Sep 17 00:00:00 2001 From: sniperc96 Date: Mon, 23 Jun 2025 14:46:57 +0800 Subject: [PATCH] change errorMsg for arkui-custom-layout Issue : https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICH5R1 Signed-off-by: sniperc96 --- ets2panda/linter/src/lib/CookBookMsg.ts | 2 +- ets2panda/linter/src/lib/TypeScriptLinter.ts | 6 +++++- ets2panda/linter/src/lib/autofixes/AutofixTitles.ts | 3 ++- ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts | 3 ++- ets2panda/linter/test/main/custom_layout.ets.arkts2.json | 6 +++--- ets2panda/linter/test/main/custom_layout.ets.autofix.json | 6 +++--- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ets2panda/linter/src/lib/CookBookMsg.ts b/ets2panda/linter/src/lib/CookBookMsg.ts index 3a9d31e001..67338049e3 100644 --- a/ets2panda/linter/src/lib/CookBookMsg.ts +++ b/ets2panda/linter/src/lib/CookBookMsg.ts @@ -280,7 +280,7 @@ cookBookTag[270] = 'ArkTS1.2 cannot catch a non Error instance thrown from JS co cookBookTag[274] = 'The subclass constructor must call the parent class\'s parametered constructor (arkts-subclass-must-call-super-constructor-with-args)'; cookBookTag[275] = - 'Custom components with custom layout capability need to add the "@CustomLayout" decorator (arkui-custom-layout-need-add-decorator)'; + 'The Custom component with custom layout capability needs to add the "@CustomLayout" decorator (arkui-custom-layout-need-add-decorator)'; cookBookTag[281] = '"@Prop" decorator is not supported (arkui-no-prop-decorator)'; cookBookTag[282] = '"@StorageProp" decorator is not supported (arkui-no-storageprop-decorator)'; cookBookTag[283] = '"@LocalStorageProp" decorator is not supported (arkui-no-localstorageprop-decorator)'; diff --git a/ets2panda/linter/src/lib/TypeScriptLinter.ts b/ets2panda/linter/src/lib/TypeScriptLinter.ts index 6bb631d6bb..cedfe8faf0 100644 --- a/ets2panda/linter/src/lib/TypeScriptLinter.ts +++ b/ets2panda/linter/src/lib/TypeScriptLinter.ts @@ -9555,7 +9555,11 @@ export class TypeScriptLinter extends BaseTypeScriptLinter { } const autofix = this.autofixer?.fixCustomLayout(node); - this.incrementCounters(node.name, FaultID.CustomLayoutNeedAddDecorator, autofix); + const name = node.name.getText(); + const errorMsg = + `The Custom component "${name}" with custom layout capability needs to add the "@CustomLayout" decorator ` + + '(arkui-custom-layout-need-add-decorator)'; + this.incrementCounters(node.name, FaultID.CustomLayoutNeedAddDecorator, autofix, errorMsg); } private handleArkTSPropertyAccess(expr: ts.BinaryExpression): void { diff --git a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts index 9a990259ea..743f8e7382 100644 --- a/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts +++ b/ets2panda/linter/src/lib/autofixes/AutofixTitles.ts @@ -64,5 +64,6 @@ export const cookBookRefToFixTitle: Map = new Map([ [339, 'Using \'ESValue\' interface call'], [341, 'Create JS objects using instantite'], [358, 'Replace missing attribute'], - [359, '"@LocalBuilder" transform to "@Builder"'] + [359, '"@LocalBuilder" transform to "@Builder"'], + [381, 'StateStyles needs arrow function block'] ]); diff --git a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts index 1f26e36e86..72a365bbd9 100644 --- a/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts +++ b/ets2panda/linter/src/lib/utils/consts/ArkTS2Rules.ts @@ -149,7 +149,8 @@ export const arkts2Rules: number[] = [ 375, 376, 377, - 378 + 378, + 381 ]; export const onlyArkts2SyntaxRules: Map = new Map([ diff --git a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json index afc0270a64..56fe9a2758 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.arkts2.json +++ b/ets2panda/linter/test/main/custom_layout.ets.arkts2.json @@ -111,7 +111,7 @@ "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout1\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -181,7 +181,7 @@ "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout2\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -271,7 +271,7 @@ "endColumn": 21, "problem": "CustomLayoutNeedAddDecorator", "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout3\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { diff --git a/ets2panda/linter/test/main/custom_layout.ets.autofix.json b/ets2panda/linter/test/main/custom_layout.ets.autofix.json index ffcc8bf530..23fd6cb93c 100644 --- a/ets2panda/linter/test/main/custom_layout.ets.autofix.json +++ b/ets2panda/linter/test/main/custom_layout.ets.autofix.json @@ -221,7 +221,7 @@ } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout1\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -368,7 +368,7 @@ } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout2\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { @@ -557,7 +557,7 @@ } ], "suggest": "", - "rule": "Custom components with custom layout capability need to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", + "rule": "The Custom component \"CustomLayout3\" with custom layout capability needs to add the \"@CustomLayout\" decorator (arkui-custom-layout-need-add-decorator)", "severity": "ERROR" }, { -- Gitee